Displaying 1 result from an estimated 1 matches for "corrhealthy".
2008 Nov 11
1
simulate data with binary outcome and correlated predictors
.... Any help on how to be as precise as possible on the betas would be nice.
Here is the code I wrote where all predictors are continuous with variance =1 and correlations between predictors vary for each condition of Y.
_________
library(MASS)
N<-1000
nbX<-3
propSick<-0.2
corrSick<-.8
corrHealthy<-.9
sigma0<-matrix(corrHealthy,nbX,nbX)
diag(sigma0)<-1
sigma1<-matrix(corrSick,nbX,nbX)
diag(sigma1)<-1
dataHealthy<-mvrnorm(N*(1-propSick),c(0,0,0),sigma0)
dataSick<-mvrnorm(N*propSick,c(1,1,1),sigma1)
dataS<-as.data.frame(matrix(0,ncol=4,nrow=N))
dimnames(dataS)[[2]]<...