



############## STEP 1
#Compile all the code in "csbigs_CodeR_simu_functions.r"
#(this is the required functions for the simulations in the article)
#For this, you can choose one of the two following commands:
source(".../csbigs_CodeR_simu_functions.r")
#or
source(file.choose())

############## STEP 2: DATA
#Read the table "Data2stCCS.csv"
#For this, you can choose one of the two following commands:
tableR=read.csv2(".../Data2stCCS.csv")
#or
tableR=read.csv2(file.choose())

attach(tableR)
N_m=544 ; N_d=365

############## STEP 3: SIMULATIONS

B=10000 ; C=50000

################ STEP 3 case 1: tY/tX

################## STEP 3 case 1: tY/tX 2d

a1=MEASURESratio2d(B,C,POPY=Yik,POPX=Xik,n_m=5,n_d=5,N_m,N_d)
b1=MEASURESratio2d(B,C,POPY=Yik,POPX=Xik,n_m=25,n_d=25,N_m,N_d)
c1=MEASURESratio2d(B,C,POPY=Yik,POPX=Xik,n_m=320,n_d=25,N_m,N_d)
d1=MEASURESratio2d(B,C,POPY=Yik,POPX=Xik,n_m=25,n_d=320,N_m,N_d)
e1=MEASURESratio2d(B,C,POPY=Yik,POPX=Xik,n_m=320,n_d=320,N_m,N_d)

result2d_1=cbind(a1,b1,c1,d1,e1)
rownames(result2d_1)=c("$n_M$","$N_M$","$n_D$","$N_D$"
,"$ParameterPOP$","$E(Parameter)$","$mbox{RB}_{MC}left(hat{Parameter}right)$"
,"$Var_{MC}$","$E(hat{V}_{2d})$","$mbox{RB}_{MC}left(hat{V}_{2d}right)$"
,"$E(hat{V}_{2d,a})$","$mbox{RB}_{MC}left(hat{V}_{2d,a}right)$")
result2d_1

################## STEP 3 case 1: tY/tX ccs

f1=MEASURESratioccs(B,C,POPY=Yik,POPX=Xik,n_m=5,n_d=5,N_m,N_d)
g1=MEASURESratioccs(B,C,POPY=Yik,POPX=Xik,n_m=25,n_d=25,N_m,N_d)
h1=MEASURESratioccs(B,C,POPY=Yik,POPX=Xik,n_m=320,n_d=25,N_m,N_d)
i1=MEASURESratioccs(B,C,POPY=Yik,POPX=Xik,n_m=25,n_d=320,N_m,N_d)
j1=MEASURESratioccs(B,C,POPY=Yik,POPX=Xik,n_m=320,n_d=320,N_m,N_d)

resultccs_1=cbind(f1,g1,h1,i1,j1)
rownames(resultccs_1)=c("$n_M$","$N_M$","$n_D$","$N_D$"
,"$ParameterPOP$","$E(Parameter)$","$mbox{RB}_{MC}left(hat{Parameter}right)$"
,"$Var_{MC}$","$E(hat{V}_{CCS})$","$mbox{RB}_{MC}left(hat{V}_{CCS}right)$"
,"$E(hat{V}_{2d})$","$mbox{RB}_{MC}left(hat{V}_{2d}right)$"
,"$E(hat{V}_{2d,a})$","$mbox{RB}_{MC}left(hat{V}_{2d,a}right)$")
resultccs_1

################ STEP 3 case 2: tZ/tX

################## STEP 3 case 2: tZ/tX 2d

a2=MEASURESratio2d(B,C,POPY=Zik,POPX=Xik,n_m=5,n_d=5,N_m,N_d)
b2=MEASURESratio2d(B,C,POPY=Zik,POPX=Xik,n_m=25,n_d=25,N_m,N_d)
c2=MEASURESratio2d(B,C,POPY=Zik,POPX=Xik,n_m=320,n_d=25,N_m,N_d)
d2=MEASURESratio2d(B,C,POPY=Zik,POPX=Xik,n_m=25,n_d=320,N_m,N_d)
e2=MEASURESratio2d(B,C,POPY=Zik,POPX=Xik,n_m=320,n_d=320,N_m,N_d)

result2d_2=cbind(a2,b2,c2,d2,e2)
rownames(result2d_2)=c("$n_M$","$N_M$","$n_D$","$N_D$"
,"$ParameterPOP$","$E(Parameter)$","$mbox{RB}_{MC}left(hat{Parameter}right)$"
,"$Var_{MC}$","$E(hat{V}_{2d})$","$mbox{RB}_{MC}left(hat{V}_{2d}right)$"
,"$E(hat{V}_{2d,a})$","$mbox{RB}_{MC}left(hat{V}_{2d,a}right)$")
result2d_2

################## STEP 3 case 2: tZ/tX ccs

f2=MEASURESratioccs(B,C,POPY=Zik,POPX=Xik,n_m=5,n_d=5,N_m,N_d)
g2=MEASURESratioccs(B,C,POPY=Zik,POPX=Xik,n_m=25,n_d=25,N_m,N_d)
h2=MEASURESratioccs(B,C,POPY=Zik,POPX=Xik,n_m=320,n_d=25,N_m,N_d)
i2=MEASURESratioccs(B,C,POPY=Zik,POPX=Xik,n_m=25,n_d=320,N_m,N_d)
j2=MEASURESratioccs(B,C,POPY=Zik,POPX=Xik,n_m=320,n_d=320,N_m,N_d)

resultccs_2=cbind(f2,g2,h2,i2,j2)
rownames(resultccs_2)=c("$n_M$","$N_M$","$n_D$","$N_D$"
,"$ParameterPOP$","$E(Parameter)$","$mbox{RB}_{MC}left(hat{Parameter}right)$"
,"$Var_{MC}$","$E(hat{V}_{CCS})$","$mbox{RB}_{MC}left(hat{V}_{CCS}right)$"
,"$E(hat{V}_{2d})$","$mbox{RB}_{MC}left(hat{V}_{2d}right)$"
,"$E(hat{V}_{2d,a})$","$mbox{RB}_{MC}left(hat{V}_{2d,a}right)$")
resultccs_2




