simDat {ecpc} | R Documentation |
Simulate data
Description
Simulate toy data with linear or logistic response.
Usage
simDat(n, p, n2 = 20, muGrp, varGrp, indT, sigma = 1,
model = c("linear","logistic"), flag = FALSE)
Arguments
n |
Number of samples for the training set. |
p |
Number of covariates. |
n2 |
Number of independent samples for the test set. |
muGrp |
Prior mean for different groups. |
varGrp |
Prior variance for different groups. |
indT |
True group index of each covariate; p-dimensional vector. |
sigma |
Variance parameter for linear model. |
model |
Type of model. |
flag |
Should linear predictors and true response be plotted? |
Value
A list with
beta |
Simulated regression coefficients |
Xctd |
Simulated observed data for training set |
Y |
Simulated response data for test set |
X2ctd |
Simulated observed data for test set |
Y2 |
Simulated response data for test set |
Examples
n<-10
p<-30
#simulate beta from two normal distributions; beta_k ~ N(mu_k,tau^2_k)
muGrp <- c(0,0.1) #mean (mu_1,mu_2)
varGrp <- c(0.05,0.01) #variance (tau^2_1,tau^2_2)
#group number of each covariate; first half in group 1, second half in group 2
indT <- rep(c(1,2),each=15)
dataLin <- simDat(n, p, n2 = 20, muGrp, varGrp, indT, sigma = 1, model = "linear",
flag = TRUE)
dataLog <- simDat(n, p, n2 = 20, muGrp, varGrp, indT, model = "logistic",
flag = TRUE)
[Package ecpc version 3.1.1 Index]