######################################################################### # This R program calculates required sample size for 1:3 matched case-control # study with a categorical exposure variable with 3 nominal levels. # p0i=Prevalence of level i of the exposure variable among the control polulation, i=0, 1,2 # p1i=Prevalence of level i of the exposure variable among the case polulation, i=0, 1,2 # psi_1, psi_2 are the two odds ratios. # M: number of controls in every matched set # Function "sample.size" calculates the required sample sizes using other functions such as # "possible.combination", "power", "pbv", "ptv", "cnd.prb", and "cond.prob". # Input variable(s): p01, p02, psi1, psi2, M # Output of the function "sample.size": Number of matched sets ########################################################################## library(nnet) possible.combination=function(M){ M1=M*(M-1)/2 amatrix=matrix(0, ncol=2, nrow=M1) x1=1; x2=0 i=0 while(x1+x2