# 1-Creation of database
## Not run:
# set.seed(13200)
# M=20000;
# fl=outc~X1+X2+gm+gnch+X1:gnch+X2:gm;
# theta=0.3
# beta=c(-0.916,0.857,0.588,0.405,-0.693,0.488)
# interc=-2.23
# vpo=c(3,4)
# vprob=c(0.35,0.55)
# vcorr=c(2,1)
# Dataf<-FtSmlrmCMCM(fl,M,theta,beta,interc,vpo,vprob,vcorr)
# rho<-table(Dataf$outc)[2]/20000 # Disease prevalence
#
# # Number of subjects eligible to the study in the population
# N=c(dim(Dataf[Dataf$outc==0,])[1],dim(Dataf[Dataf$outc==1,])[1])
#
# # Sampling of the study database
# n0=1232;n1=327;
# DatfE1<-SeltcEch("outc",n1,n0,"obs",Dataf)
#
#
# # 2 Creation of missing data on the offspring genotype
# DatfE=DatfE1
# gnch<-DatfE["gnch"]
# gnch<-as.vector(gnch[,1])
# gnch1<-sample(c(0,1),length(gnch),replace=TRUE,prob=c(0.91,0.09))
# gnch[gnch1==1]<-NA
# DatfE=DatfE1
# DatfE$gnch<-NULL;DatfE$gnch<-gnch
# # 3 Creation of the two databases
# # DatfEcd :complete data
# # DatfEmd :data with missing genotypes for a subset of children.
# DatfEcd<-DatfE[is.na(DatfE["gnch"])!=TRUE,]
# DatfEmd<-DatfE
# rm(gnch);rm(gnch1)
# # data obtained
# DatfEcd[26:30,]
# DatfEmd[26:30,]
#
# ##4 Estimation of parameters=======================================================
# ## model equation
# fl=outc~X1+X2+gm+gnch+X1:gnch+X2:gm;
# ## Estimation of the parameters (no missing data)
# # N = (N0,N1) is available
# Rsnm1<-Spmlficmcm(fl,N,"gm","gnch",DatfEcd,1)
# #solution of the nonlinear system
# round(Rsnm1$Uim,digits=3)
# #estimates
# round(Rsnm1$MatR,digits=3)
# #variance - covariance matrix
# round(Rsnm1$Matv,digits=5)
# # N = (N0,N1) is not available
# Rsnm2<-Spmlficmcm(fl=fl,gmname="gm",gcname="gnch",DatfE=DatfEcd,typ=1,p=rho)
# #solution of the nonlinear system
# round(Rsnm2$Uim,digits=3)
# #estimates
# round(Rsnm2$MatR,digits=3)
# #variance - covariance matrix
# round(Rsnm2$Matv,digits=5)
# ## Estimation of the parameters (with missing data)
# # N = (N0,N1) is available
# Rswm1<-Spmlficmcm(fl,N,"gm","gnch",DatfEmd,typ=2)
# #solution of the nonlinear system
# round(Rswm1$Uim,digits=3)
# #estimates
# round(Rswm1$MatR,digits=3)
# #variance - covariance matrix
# round(Rswm1$Matv,digits=5)
# # N = (N0,N1) is not available
# Rswm2<-Spmlficmcm(fl=fl,gmname="gm",gcname="gnch",DatfE=DatfEmd,typ=2,p=rho)
# #solution of the nonlinear system
# round(Rswm2$Uim,digits=3)
# #estimates
# round(Rswm2$MatR,digits=3)
# #variance - covariance matrix
# round(Rswm2$Matv,digits=5)
# ## End(Not run)
Run the code above in your browser using DataLab