Examples¶
Each page here follows one of the scripts in
examples/ of
the repository: it explains what the script shows, with its output, and
ends with the script itself, which you can download from the link at the top
of the page. The scripts run on simulated data from logit_stream.simulate,
so there is nothing else to download and nothing to configure. Each script
stands alone, so a downloaded one runs anywhere logit-stream is installed:
pip install logit-stream
python quickstart.py
or, from a clone of the repository, python examples/quickstart.py. Most
take a few seconds; the random-intercepts and mixed-logit examples take
about a minute, since they fit several models each. The scripts that write
files put them in an output/ directory next to the script, which you can
delete afterwards. The outputs shown on these pages are from those runs,
abridged; your numbers may differ in the last digits.
every estimator once, and the reporting and prediction methods they share. Start here. |
|
the logit and probit with fixed effects, and Firth’s penalized likelihood for separation |
|
parameterization, standard errors (robust, clustered, multi-way, jackknife), weights, ridge |
|
cutpoints, levels, residuals and predictions |
|
long-format choice data, alternative-specific constants, policy scenarios |
|
nests of alternatives, the dissimilarity parameters, substitution, deeper trees |
|
random coefficients, panels of repeated choices, simulation draws |
|
absorbing a fixed effect in the multinomial and ordered logit, and several |
|
group intercepts with an estimated covariance, nested groupings, shrinkage |
|
the fixed-effects logit’s bias in short panels, the bias correction, and Chamberlain’s conditional logit |
|
predicting a characteristic for a large file, and combining the predictions with other information |
The simulated data¶
logit_stream.simulate ships with the package, so you can try the
estimators, or check your own code, on data whose answer you know (see
the reference):
simulate_peopleis a population shaped like the demographic imputation problem: people in PUMAs nested in states, with age, sex, income and household characteristics, and three outcomes drawn from logit models of them – Hispanic origin (binary), race and ethnicity (six categories) and educational attainment (five ordered levels) – each with PUMA effects.truth_peoplereturns the coefficients it draws from.simulate_choicesis long-format mode-choice data (train, metro, car), in the shape of the Swissmetro survey, drawn from the conditional logit; withnests=from the nested logit, and withtasks=andsd_time=from the mixed logit with a panel of repeated choices.simulate_panelis a panel with a binary outcome and unit effects correlated with a covariate, for the fixed-effects logit.