simulate_data: Simulate data with hierarchical subspaces

Description Usage Arguments Value Examples

View source: R/simulate_data.R

Description

Simulates data with hierarchical subspaces. Data are generated with two factors that induce heterogeneity

Usage

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")
)

Arguments

nobs

positive integer for the sample size per subpopulation

nvars

positive integer for the dimension

x.type

variable type for covariates, either "continuous" (where the covariates are multivariate normal with a variance-matrix with AR-1 form with parameter rho) or "some_categorical" (where half covariates are continuous and the other half are binary with dependencies on the continuous covariates)

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

Value

A list with the following elements

Examples

 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

hierSDR documentation built on Sept. 24, 2021, 1:06 a.m.