Predicted Values and Discrete Changes for Regression Models

Functions to calculate predicted values and the difference between the two cases with confidence interval for lm() [linear model], glm() [generalized linear model], glm.nb() [negative binomial model], polr() [ordinal logistic model], vglm() [generalized ordinal logistic model], multinom() [multinomial model], tobit() [tobit model], svyglm() [survey-weighted generalised linear models] and lmer() [linear multilevel models] using Monte Carlo simulations or bootstrap. Reference: Bennet A. Zelner (2009) .


glm.predict

R GNU Package to simulate/bootstrap predicted values/probabilities and discrete changes for lm(), glm(), glm.nb(), polr(), multinom(), tobit() and lmer() models.

Example

Here an example how you can use the function predicts(). First we estimate an logistic regression to predict the gender of a person using height, smoking and pulse as independent variables.

model1 = glm(Sex ~ Height + Smoke + Pulse, data=MASS::survey, family=binomial(link=logit))

Now we can estimate predicted probabilities. For Height we take 150, 170 and 190, for Smoke we take all levels of the factor and for Pulse we take the average value of the data. We set a seed to always get the same results.

library(glm.predict)
predicts(model1, "150-190,20;all;mean", set.seed = 1848)

By setting position to the position of a variable, we can get discrete changes for that specific variable. If we want to get the difference between 150 and 170 body size, we can do that in the following way:

predicts(model1, "150,170;all;mean", set.seed = 1848, position = 1)

To get all possible values and other parameters you can read the documentation:

?predicts()

Installation

If you want to install the stable version from CRAN you can do that with the following command:

install.packages("glm.predict")

If you want to install the newest developer version from GitHub, you can do that with the package remotes:

install.packages("remotes")
remotes::install_github("benjaminschlegel/glm.predict")

You might need to install Rtools (for Windows) or XCode (for Mac OS) to install the package from GitHub.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("glm.predict")

4.3-2 by Benjamin E. Schlegel, a year ago


https://github.com/benjaminschlegel/glm.predict/


Browse source code at https://github.com/cran/glm.predict


Authors: Benjamin E. Schlegel [aut, cre] (ORCID:


Documentation:   PDF Manual  


GPL (>= 2) license


Imports nnet, AER, survival, MASS, parallel, mlogit, dfidx, survey, lme4, VGAM

Depends on stats

Suggests ggplot2, devtools, knitr, rmarkdown


See at CRAN