PathSelectMP-package: Backwards Variable Selection for paths using M Plus

Description Details Author(s) References Examples

Description

M Plus must be installed. This package is primarily for use with datasets containing only categorical variables, although continous variables may be included as independent variables in paths. Backward variable selection is performed on all Total, Total Indirect, and then Direct effects until none of these effects have p-values greater than the specified target p-value. In some cases a given starting set of paths may produce singularity issues, in which case, the user should revise the set of possible paths. It's very important to delete all folders which are specified in Initialize and other functions where M Plus is called to read and write .inp and .out files. Or if the default is used and the user doesn't specify directories and folders, delete the default folder used before performing selection again or peforming with a new example with the same default folder name

Details

Package: PathSelectMP
Type: Package
Version: 1.0
Date: 2016-04-20
License: GPL (>= 2)

The most important functions to use are Simulate to simulate data for an example, Initialize to write initial paths and input file, AllBackwardSelect to perform backwards selection with .inp and .out files saved in current working directory or user specified directory, AllSummary2 for a summary of all direct effects, CreateTotalSummary for a summary of all total effects, CalculatRiskRatios to calculate direct effect risk ratios, TotalRiskRatios to calculate total effect risk ratios, and AverageRRs to calculate average risk ratios for direct effects or total effects when comparing multiple imputed datasets.

It is recommended to follow and review examples since many functions require other functions to be run first and certain data files to be saved and created before running a function. Also note that all variable names must begin with a capital letter and contain only letters and numbers in this version.

Author(s)

William Terry, Meredith Ray, Hongmei Zhang

Maintainer: <hzhang6@memphis.edu>

References

MPlus, MPlusAutomation, mice

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
## 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)

## End(Not run)

PathSelectMP documentation built on May 2, 2019, 3:15 a.m.