if(Distributionx=="Normal"){ if(Independentx){ Age <- rnorm(n,0,sigmaAge) CD4 <- rnorm(n,0,sigmaCD4) } else{ Age <- rnorm(n,0,sigmaAge) CD4 <- rnorm(n,rho*sigmaCD4/sigmaAge*Age,sqrt(1-rho^2)*sigmaCD4) } if(Linear){ ##this is for the linear estimate ##this is how x affects r trueh1 <- (Age/sigmaAge)*ES.AGE trueh2 <- (CD4/sigmaCD4)*ES.CD4 trueeta <- logit(PM) - truealpha*MEANCD4 trueh <- trueeta+trueh1+trueh2 ##this is how x affects y truef1 <- -Age; truef1 <- truef1*ES2.AGE truef2 <- CD4 ; truef2 <- truef2*ES2.CD4 trueeta2 <- MEANCD4 truef <- truef1+truef2+trueeta2 } else{ trueh1 <- (H1(Age) - h1mean)/h1SD*ES.AGE trueh2 <- (H2(CD4) - h2mean)/h2SD*ES.CD4 trueeta <- logit(PM) - truealpha*MEANCD4 trueh <- trueeta+trueh1+trueh2 truef1 <- (F1(Age) - f1mean)/f1SD*ES2.AGE truef2 <- (F2(CD4) -f2mean)/f2SD*ES2.CD4 trueeta2 <- MEANCD4 truef <- truef1+truef2+trueeta2 } } if(Distributionx=="Unif"){ ##we always do non linear with this one. Age <- c(runif(na1,MINAGE,MIDAGE),runif(na2,MIDAGE,MAXAGE)) CD4 <- c(runif(nc1,MIDCD4,MAXCD4),runif(nc2,MINCD4,MIDCD4)) if(Independentx){ Age <- sample(Age) CD4 <- sample(CD4) } trueh1 <- (H1(Age) - h1mean)/h1SD*ES.AGE trueh2 <- (H2(CD4) - h2mean)/h2SD*ES.CD4 trueeta <- logit(PM) - truealpha*MEANCD4 trueh <- trueeta+trueh1+trueh2 truef1 <- (F1(Age)- f1mean)/f1SD*ES2.AGE truef2 <- (F2(CD4)-f2mean)/f2SD*ES2.CD4 trueeta2 <- MEANCD4 truef <- truef1+truef2+trueeta2 } X <-cbind(rep(1,n),(Age-mean(Age))/sqrt(var(Age)),(CD4-mean(CD4))/sqrt(var(CD4)))