##CONSTANT DEFINITIONS NN <- 500#number of iterations BB <- 150 #number of bootstrap iterations. only for bootstrap. consider smaller NN for bootstrap simulation. ###This defines what the distribution to be used will be #Distributiony <- "Normal";truealpha <- -.001;Q <- function(x) x Distributiony <- "Lognormal";truealpha <- 1;Q <- function(x) log(x) Distributionx <- "Normal"; sigmaAge <- 10; sigmaCD4 <- 100; #Distributionx <- "Unif" Independentx <- F; rho <- -.25 Linear <-F ##are the truefs and truehs linear or not. ###Effects MEANCD4 <- 5.4 #mean of y. if lognormal it should change to mean og log(y) sigmay <- .05##as above but the sd ofy. should change if lognormal ES.AGE <- .4#this is how strong the effect of age on r is ES.CD4 <- .2##this is hos strong the effect of cd4 on r is ES2.CD4 <- .1#*sigmay #this is how strong the effect of cd4 is on y. ES2.AGE <- .15#*sigmay #this is how strong effect ofg age on y ##NOTE, if using linear hs and fs do not multiply ny sigmay in previous two n <- 619 ##this is sample size PM <- .3##average probability of missing alphas <- truealpha#c(-5,-2,0)#truealpha ##these are the alphas to try DFS <-c(12,8,6,4,3,2,1)#seq(8,1,-1)#these are the degrees of freedom for the h1 DFS2 <- DFS#rep(3,length(DFS))#c(6,5,4,3,2) ##this is for the h2, must be same length DFS DFS3 <- c(30,24,18,12,6,2,1)#these are teh degrees of freedom for the fs to try ###ONE HAS TO BE FIRST in both DFS! ##DF3 will also be used for orthogonal estimator MAXDF <- 24 ##high degree of freedom to get started maxh <- 750 ##if h is bigger than this its too big epsilon <- 10^-3##stopping criterion GRIDSIZE <- 1000 ##this is the size of grid for log normal look up table Maxcount <- 15 #maximum nuumber of iteration in gam ###here we define the functions ##below are calculations of mean and sd of truef1, truef2 etc.. ##below here should not change unless model-generation.S chagnes. if(!Linear){ H1 <- function(x) (MIDAGE-x)*(x > MIDAGE) H2 <- function(x) (x-MIDCD4)^2 F1 <- function(x) - x + 0.65*(x-MIDAGE)*(x>MIDAGE) F2 <- function(x) -(MIDCD4-x)^2 ##functions need for trueh,etc.. to have mean0 NNN <- 500000 if(Distributionx=="Normal"){ if(Independentx) { Age <- rnorm(NNN,0,sigmaAge) CD4 <- rnorm(NNN,0,sigmaCD4) } else{ Age <- rnorm(NNN,0,sigmaAge) CD4 <- rnorm(NNN,rho*sigmaCD4/sigmaAge*Age,sqrt(1-rho^2)*sigmaCD4) } MIDAGE <- -1.5*sigmaAge;MIDCD4 <- 3*sigmaCD4 trueh1 <- H1(Age) trueh2 <- H2(CD4) truef1 <- F1(Age) truef2 <- F2(CD4) h1mean <- mean(trueh1) h1SD <- sd(trueh1) f1mean <- mean(truef1) f1SD <- sd(truef1) h2mean <- mean( trueh2) h2SD <- sd( trueh2) f2mean <- mean( truef2) f2SD <- sd( truef2) } if(Distributionx=="Unif"){ ##We redefine MIDAGE etc.. MINAGE <- 18;MIDAGE <- 35;MAXAGE <- 70 MINCD4 <- 10; MIDCD4 <- 800; MAXCD4 <- 900 na1 <- round(.1*n);na2 <-n-na1 # na1/n is percent "young" nc1 <- round(.1*n);nc2 <- n-nc1#nc1/n is pecent "healthy" 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) trueh2 <- H2(CD4) truef1 <- F1(Age) truef2 <- F2(CD4) h1mean <- mean(trueh1) h1SD <- sd(trueh1) f1mean <- mean(truef1) f1SD <- sd(truef1) h2mean <- mean( trueh2) h2SD <- sd( trueh2) f2mean <- mean( truef2) f2SD <- sd( truef2) } }