Skip to content

Commit

Permalink
documentation update
Browse files Browse the repository at this point in the history
  • Loading branch information
therimalaya committed Nov 15, 2022
1 parent 0b7cb3c commit fecd13c
Show file tree
Hide file tree
Showing 16 changed files with 4,514 additions and 3,383 deletions.
5 changes: 5 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.Rprofile
^renv$
^renv\.lock$
^codecov\.yml$
^_pkgdown\.yml$
^.*\.Rproj$
Expand All @@ -24,3 +27,5 @@ CONTRIBUTING.md

^CRAN-RELEASE$
^cran-comments\.md$
^doc$
^Meta$
1 change: 1 addition & 0 deletions .Rprofile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source("renv/activate.R")
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
.Ruserdata
/.Rapp.history
internal/
/doc/
/Meta/
renv
13 changes: 7 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Depends:
R (>= 3.5.0)
License: GPL-3
Encoding: UTF-8
RoxygenNote: 7.1.2
RoxygenNote: 7.2.1
VignetteBuilder: knitr
BugReports: https://github.com/simulatr/simrel/issues
URL: https://simulatr.github.io/simrel/
Expand All @@ -35,20 +35,21 @@ Imports:
gridExtra,
jsonlite,
magrittr,
methods,
miniUI,
purrr,
reshape2,
rlang,
rstudioapi,
scales,
sfsmisc,
shiny,
testthat,
tibble,
tidyr,
rlang,
testthat
tidyr
Suggests:
DoE.base,
covr,
knitr,
pls,
markdown,
DoE.base
pls
2 changes: 1 addition & 1 deletion R/ggsimrelplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' @param use_population Logical, TRUE if population values should be used and FALSE if sample values should be used
#' @return A list of plots
#' @examples
#' sim.obj <- simrel(n = 100, p = 16, q = c(3, 4, 5),
#' sim.obj <- simrel(n = 50, p = 16, q = c(3, 4, 5),
#' relpos = list(c(1, 2), c(3, 4), c(5, 7)), m = 5,
#' ypos = list(c(1, 4), 2, c(3, 5)), type = "multivariate",
#' R2 = c(0.8, 0.7, 0.9), gamma = 0.8)
Expand Down
103 changes: 73 additions & 30 deletions R/simrel.r
Original file line number Diff line number Diff line change
@@ -1,37 +1,80 @@
#' Simulation of Multivariate Linear Model Data
#' @param n Number of observations.
#' @param p Number of variables.
#' @param q An integer for univariate, a vector of 3 integers for bivariate and 3 or more for multivariate simulation (for details see Notes).
#' @param relpos A list (vector in case of univariate simulation) of position of relevant component for predictor variables corresponding to each response.
#' @param gamma A declining (decaying) factor of eigenvalues of predictors (X). Higher the value of \code{gamma}, the decrease of eigenvalues will be steeper.
#' @param R2 Vector of coefficient of determination (proportion of variation explained by predictor variable) for each relevant response components.
#' @param type Type of simulation - \code{univariate}, \code{bivariate} and \code{multivariate}
#' @param ... Since this is a wrapper function to simulate univariate, bivariate or multivariate, it calls their respective function. This parameter should contain all the necessary arguements for respective simulations. See \code{\link{unisimrel}}, \code{\link{bisimrel}} and \code{\link{multisimrel}}
#' @return A simrel object with all the input arguments along with following additional items.
#' \item{X}{Simulated predictors}
#' \item{Y}{Simulated responses}
#' \item{W}{Simulated predictor components}
#' \item{Z}{Simulated response components}
#' \item{beta}{True regression coefficients}
#' \item{beta0}{True regression intercept}
#' \item{relpred}{Position of relevant predictors}
#' \item{testX}{Test Predictors}
#' \item{testY}{Test Response}
#' \item{testW}{Test predictor components}
#' \item{testZ}{Test response components}
#' \item{minerror}{Minimum model error}
#' \item{Xrotation}{Rotation matrix of predictor (R)}
#' \item{Yrotation}{Rotation matrix of response (Q)}
#' \item{type}{Type of simrel object \emph{univariate} or \emph{multivariate}}
#' \item{lambda}{Eigenvalues of predictors}
#' \item{SigmaWZ}{Variance-Covariance matrix of components of response and predictors}
#' \item{SigmaWX}{Covariance matrix of response components and predictors}
#' \item{SigmaYZ}{Covariance matrix of response and predictor components}
#' \item{Sigma}{Variance-Covariance matrix of response and predictors}
#' \item{RsqW}{Coefficient of determination corresponding to response components}
#' \item{RsqY}{Coefficient of determination corresponding to response variables}
#' @param q Number of predictors related to each relevant components
#' An integer for univariate, a vector of 3 integers for bivariate and 3 or
#' more for multivariate simulation (for details see Notes).
#' @param relpos A list (vector in case of univariate simulation) of position
#' of relevant component for predictor variables corresponding
#' to each response.
#' @param gamma A declining (decaying) factor of eigenvalues of predictors (X).
#' Higher the value of \code{gamma}, the decrease of eigenvalues
#' will be steeper.
#' @param R2 Vector of coefficient of determination (proportion of variation
#' explained by predictor variable) for each relevant response components.
#' @param type Type of simulation - \code{univariate}, \code{bivariate} and
#' \code{multivariate}
#' @param ... Since this is a wrapper function to simulate univariate,
#' bivariate or multivariate, it calls their respective function.
#' This parameter should contain all the necessary arguements for respective
#' simulations. See \code{\link{unisimrel}}, \code{\link{bisimrel}} and
#' \code{\link{multisimrel}}
#' @return A simrel object with all the input arguments along with
#' following additional items. For more detail on the return values see the
#' individual simulation functions \code{\link{unisimrel}},
#' \code{\link{bisimrel}} and \code{\link{multisimrel}}.
#'
#' \strong{Common returns from univariate, bivariate and multivariate simulation:}
#'
#' \item{call}{the matched call}
#' \item{X}{simulated predictors}
#' \item{Y}{simulated responses}
#' \item{beta}{true regression coefficients}
#' \item{beta0}{true regression intercept}
#' \item{relpred}{position of relevant predictors}
#' \item{n}{number of observations}
#' \item{p}{number of predictors (as supplied in the arguments)}
#' \item{p}{number of responses (as supplied in the arguments)}
#' \item{q}{number of relevant predictors (as supplied in the arguments)}
#' \item{gamma}{declining factor of eigenvalues of predictors
#' (as supplied in the arguments)}
#' \item{lambda}{eigenvalues corresponding to the predictors}
#' \item{R2}{theoretical R-squared value (as supplied in the arguments)}
#' \item{relpos}{position of relevant components (as supplied in the arguments)}
#' \item{minerror}{minimum model error}
#' \item{Sigma}{variance-Covariance matrix of response and predictors}
#' \item{testX}{simulated test predictor (in univarite simulation \code{TESTX})}
#' \item{testY}{simulated test response (in univarite simulation \code{TESTY})}
#' \item{Rotation}{Random rotation matrix used to rotate latent components. Is
#' equivalent to the transpose of eigenvector-matrix. In multivariate
#' simulation, \code{Xrotation} (R) and \code{Yrotation} (Q) refers to this matrix
#' corresponding to the predictor and response.}
#' \item{type}{type of simrel object \code{univariate}, \code{bivariate} or
#' \emph{multivariate}}
#'
#' \strong{Returns from multivariate simulation:}
#'
#' \item{eta}{a declining factor of eigenvalues of response (Y)
#' (as supplied in the arguments)}
#' \item{ntest}{number of simulated test observations}
#' \item{W}{simulated response components}
#' \item{Z}{simulated predictor components}
#' \item{testW}{test predictor components}
#' \item{testZ}{test response components}
#' \item{SigmaWZ}{Variance-Covariance matrix of components of response and predictors}
#' \item{SigmaWX}{Covariance matrix of response components and predictors}
#' \item{SigmaYZ}{Covariance matrix of response and predictor components}
#' \item{RsqW}{Coefficient of determination corresponding to response components}
#' \item{RsqY}{Coefficient of determination corresponding to response variables}
#'
#' @concept simulation
#' @concept linear model data
#' @note The parameter \code{q} represents the number of predictor variables
#' that forms a basis for each of the relevant components. For example,
#' for \code{q = 8} and relevant components 1, 2, and 3 specified by
#' parameter \code{relpos} then the randomly selected 8 predictor variables
#' forms basis for these three relevant components and thus in the model
#' these 8 predictors will be relevant for the response (outcome).
#' @keywords datagen
#' @references Sæbø, S., Almøy, T., & Helland, I. S. (2015). simrel—A versatile tool for linear model data simulation based on the concept of a relevant subspace and relevant predictors. Chemometrics and Intelligent Laboratory Systems, 146, 128-135.
#' @references Almøy, T. (1996). A simulation study on comparison of prediction methods when only a few components are relevant. Computational statistics & data analysis, 21(1), 87-107.
Expand Down Expand Up @@ -103,7 +146,7 @@ simrel <- function (n, p, q, relpos, gamma, R2, type = "univariate", ...) {
stopMsg <-
append(stopMsg, "Decaying factor of eigenvalues in univariate simulation must be specified by a number between 0 and 1.")
if (!is.null(sim))
if (class(sim) == "simrel") stopMsg <- append(stopMsg, "Unknown simulation object.")
if (methods::is(sim, "simrel")) stopMsg <- append(stopMsg, "Unknown simulation object.")
if (!is.null(muX))
if (length(muX) != p) stopMsg <- append(stopMsg, "Please input mean vector of correct dimension.")

Expand Down
4 changes: 2 additions & 2 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
authors:
Raju Rimal:
href: http://mathatistics.com
href: https://mathatistics.com
Solve Sæbø:
href: http://solvsa.nmbu.no
href: https://solvsa.nmbu.no
navbar:
right:
- icon: fa-github fa-lg
Expand Down
60 changes: 0 additions & 60 deletions docs/bootstrap-toc.css

This file was deleted.

2 changes: 1 addition & 1 deletion man/ggsimrelplot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

102 changes: 73 additions & 29 deletions man/simrel.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fecd13c

Please sign in to comment.