convertbaselineltolr: Convert a baseline logit model data set, formatted in the...

Description Usage Arguments Details Value References Examples

View source: R/convertbaselineltolr.R

Description

Convert a baseline logit model data set, formatted in the long form as described in the documentation for mlogit.data from mlogit package, to a conditional logistic regression.

Usage

1
convertbaselineltolr(dataset, choice, covs, strs = "chid", alt = "alt")

Arguments

dataset

in formatted as in the output from mlogit.data of the mlogit packages

choice

name of variable in dataset representing choice, a logical variable indicating whether this choice is actually chosen.

covs

vector of names of covariates

strs

name of variable in data set indicating independent subject

alt

name of variable in data set indicating potential choice.

Details

This function implements version of \insertCitekolassa16PHInfiniteEstimates. The multinomial regression is converted to a conditional logistic regression, and methods of \insertCitekolassa97PHInfiniteEstimates may be applied. This function differs from convertmtol of this package in that convertmtol treats a less-rich data structure, and this function treats the richer data structure that is an output of mlogit.data from package mlogit. Data in the example is from \insertCitebes;textualPHInfiniteEstimates.

Value

a data set on which to apply conditional logistic regression, corresponding to the baseline logit model.

References

\insertRef

besPHInfiniteEstimates

\insertRef

kolassa97PHInfiniteEstimates

\insertRef

kolassa16PHInfiniteEstimates

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
data(voter.ml)
covs<-c("Labor","Liberal.Democrat","education")
#Fit the multinomial regression model, for comparison purposes.
## Lines beginning ## give mlogit syntax that has been made obsolete.
#Add the index attribute to the data set, giving the index of choice made and the index of the 
#alternative, and a boolean variable giving choice.
##attributes(voter.ml)$index<-voter.ml[,c("chid","alt")]
##attributes(voter.ml)$choice<-"voter"
##mlogit(voter~1|Labor+Liberal.Democrat+education,data=voter.ml)
mlogit(voter~1|Labor+Liberal.Democrat+education,data=voter.ml, 
   chid.var = "chid", alt.var = "alt")
#Convert to a data set allowing treatment as the equivalent conditional logistic regression.  
#This result will be processed using reduceLR of this package to give an equivalent conditional
# regression model avoiding infinite estimates.
out<-convertbaselineltolr(voter.ml,"voter",c("Labor","Liberal.Democrat","education"))
#Fit the associated unconditional logistic regression for comparison purposes.
glm(out[,"y"]~out[,1:75],family=binomial)

PHInfiniteEstimates documentation built on July 24, 2021, 1:07 a.m.