convertbaselineltolr {PHInfiniteEstimates} | R Documentation |
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.
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
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 (Kolassa 2016).
The multinomial regression is converted to a conditional logistic regression, and methods of (Kolassa 1997) 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 Sanders et al. (2007).
Value
a data set on which to apply conditional logistic regression, corresponding to the baseline logit model.
References
Sanders DJ, Whiteley PF, Clarke HD, Stewart M, Winters K (2007). “The British Election Study.” https://www.britishelectionstudy.com.
Kolassa JE (1997). “Infinite Parameter Estimates in Logistic Regression.” Scandinavian Journal of Statistics, 24, 523–530. doi:10.1111/1467-9469.00078.
Kolassa JE (2016). “Inference in the Presence of Likelihood Monotonicity for Polytomous and Logistic Regression.” Advances in Pure Mathematics, 6, 331-341. doi:10.4236/apm.2016.65024.
Examples
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)
# The package mlogit is scheduled for archiving. If it is available, the
# next two lines fit the model using mlogit.
# 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)