# NOT RUN {
#example 1
#creates generated data set and stores as InitD
InitD=Simulate(exampleNum=1)
xxx=Initialize(InitD,WhichCat=c(1,1,1,1,1))
ggg=AllBackwardSelect(xxx[[1]])
yyy=AllSummary2(xxx[[1]])
yyy$DirectEffects
AllDat1=ConvertData2(xxx[[1]],xxx[[2]],yyy[[1]])
www=CalculatRiskRatios(AllDat1[[1]],NADes=c(-99),WhichCat=c(1,1,1,1,1),
WhichRiskCalc=c(0,0,0,0,0))
www=CalculatRiskRatios(AllDat1[[1]],NADes=c(-99),WhichCat=c(1,1,1,1,1),
WhichRiskCalc=c(0,0,list(c(3,4,5)),0,0))
RRT1=lapply(AllDat1,TotalRiskRatios,InputDepVal=1)
#example 2
Simulated=Simulate(n=900,MissingYN=1,exampleNum=2)
#MissingYN is 1 for add missing data 0 is default which is don't add missing data
uu=Initialize(Simulated,NumImpute=3,WhichCat=c(1,1,1,1,1,0,1,0,0),
DataFileName="Example2",NameFile="Example2D",
Directry=getwd(),WhichRowsImp=c(1:450))
#NumImpute is the number of imputed datasets
AB=AllBackwardSelect(uu[[1]],Directry=getwd(),PSig=0.04)
DE=AllSummary2(uu[[1]],Directry=getwd())
DE$DirectEffects
AllDat1=ConvertData2(uu[[1]],uu[[2]],DE[[1]])
wwwA=lapply(AllDat1,CalculatRiskRatios,NADes=c(-99),
Directry=getwd(),
WhichCat=c(1,1,1,1,1,0,1,0,0),WhichRiskCalc=c(0,0,0,0,0,0,0,0,0))
AvgwwwA=AverageRRs(wwwA,GreaterThanCountNum=0)
#Average Risk Ratios for direct effects
RRT1=lapply(AllDat1,TotalRiskRatios,InputDepVal=1,
Directry=getwd())
RRT1avg=AverageRRs(RRT1,GreaterThanCountNum=0)
TotsAllEff=AllTotalEffOutput(AllDat1,Directry=getwd())
NewNamesThresh(FileName="Example2D_1000",DataName="Example2_1000",ThreshName="G$2",
InitialData=Simulated,Directry=getwd(),NADes=c(-99))
#example 3
#Note if not specifying a new directory or filename as below,
#make sure files from example 1 are deleted
#otherwise this example won't work
InitD=Simulate(MissingYN=0,exampleNum=3)
InitializeMat=matrix(c(rep(0,ncol(InitD)*ncol(InitD))),nrow=ncol(InitD))
InitializeMat[upper.tri(InitializeMat)]=1
InitializeMat=data.frame(InitializeMat)
names(InitializeMat)=names(InitD)
row.names(InitializeMat)=names(InitD)
InitializeMat[8,]=c(0,0,0,0,0,0,0,0)
InitializeMat[6,]=c(0,0,0,0,0,0,0,0)
xxx=Initialize(InitD,NumImpute=0,WhichCat=c(1,1,1,1,1,0,1,0),
InputInitializeMat=InitializeMat,PasteIND=1,DataFileName="Example3",NameFile="Example3D")
#If PasteIND=0 then we are not examining all indirect effects this can be
#used for larger numbers of variables in data sets but default it PasteIND=1
ggg=AllBackwardSelect(xxx[[1]])
yyy=AllSummary2(xxx[[1]])
AllDat1=ConvertData2(xxx[[1]],xxx[[2]],yyy[[1]])
www=CalculatRiskRatios(AllDat1[[1]],NADes=c(-99),WhichCat=c(1,1,1,1,1,0,1,0)
,WhichRiskCalc=c(0,0,0,0,0,0,0,0))
RRT1=lapply(AllDat1,TotalRiskRatios,InputDepVal=1)
# }
Run the code above in your browser using DataLab