Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

R GNU Package to calculate discrete changes for glm models

NotificationsYou must be signed in to change notification settings

benjaminschlegel/glm.predict

Repository files navigation

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 functionpredicts(). 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.

About

R GNU Package to calculate discrete changes for glm models

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp