Description Usage Arguments Details Value References Examples

View source: R/convertbaselineltolr.R

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.

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

`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. |

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.

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

besPHInfiniteEstimates

\insertRefkolassa97PHInfiniteEstimates

\insertRefkolassa16PHInfiniteEstimates

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)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.