Description Usage Arguments Value Examples
View source: R/simulate_data.R
Simulates data with hierarchical subspaces. Data are generated with two factors that induce heterogeneity
1 2 3 4 5 6 7 8 | simulate_data(
nobs,
nvars,
x.type = c("continuous", "some_categorical"),
sd.y = 1,
rho = 0.5,
model = c("1", "2", "3")
)
|
nobs |
positive integer for the sample size per subpopulation |
nvars |
positive integer for the dimension |
x.type |
variable type for covariates, either |
sd.y |
standard deviation of responsee |
rho |
correlation parameter for AR-1 covariance structure for continuous covariates |
model |
model number used, either "1", "2", or "3", each corresponds to a different outcome model setting |
A list with the following elements
x a matrix of covariates with number of rows equal to the total sample size and columns equal to the number of variables
z a matrix with number of rows equal to the total sample size and columns as dummy variables indicating presence of a stratifying factor
y a vector of all responses
beta a list of the true sufficient dimension reduction matrices, one for each subpopulation
z.combinations all possible combinations of the stratifying factors z
snr scalar the observed signal-to-noise ratio for the response
d.correct the true dimensions of the dimension reduction spaces
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | library(hierSDR)
set.seed(123)
dat <- simulate_data(nobs = 100, nvars = 6,
x.type = "some_categorical",
sd.y = 1, model = 2)
x <- dat$x ## covariates
z <- dat$z ## factor indicators
y <- dat$y ## response
dat$beta ## true coefficients that generate the subspaces
dat$snr ## signal-to-noise ratio
str(x)
str(z)
dat$z.combinations ## what combinations of z represent different subpops
## correct structural dimensions:
dat$d.correct
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.