######################################### # function "casecontrol" calls "ftns.R" # ######################################### casecontrol = function(r0,r1,r2,s0,s1,s2,N_bootstrap){ source("casecontrol_ftns.R") xx = matrix(c(r0,r1,r2,s0,s1,s2),nrow=2,byrow=T) x = 0 trendt = ftn_catt(xx,c(0,x,1)) z0 = trendt$estimate pz0 = trendt$p.value x = 0.5 trendt = ftn_catt(xx,c(0,x,1)) z0.5 = trendt$estimate pz0.5 = trendt$p.value x = 1 trendt = ftn_catt(xx,c(0,x,1)) z1 = trendt$estimate pz1 = trendt$p.value chit = chisq.test(xx) chi2 = chit$statistic pchi2 = chit$p.value min2 = min(pz0.5,pchi2) pmin2 = ftn_pmin2(min2) CLRT = ftn_CLRT(r0,r1,r2,s0,s1,s2) MAX = max(abs(z0),abs(z0.5),abs(z1)) output = ftn_p_MAX_CLRT(N_bootstrap,r0,r1,r2,s0,s1,s2,MAX,CLRT) pMAX = output$pMAX pCLRT = output$pCLRT output = list(REC = c(z0,pz0), ADD = c(z0.5,pz0.5), DOM = c(z1,pz1), CHI2=c(chi2,pchi2),MAX3 = c(MAX,pMAX), CLRT=c(CLRT,pCLRT),MIN2=c(min2,pmin2)) return(output) } # end function casecontrol #r0 = 25 #r1 = 274 #r2 = 387 #s0 = 65 #s1 = 251 #s2 = 353 #casecontrol(r0,r1,r2,s0,s1,s2,1000000)