Type: | Package |
Title: | Computing Logit & Probit Predicted Probabilities & Marginal Effects |
Version: | 1.0.1 |
Date: | 2020-06-27 |
Author: | Tim Liao |
Maintainer: | Tim Liao <tfliao@illinois.edu> |
Description: | Computes predicted probabilities and marginal effects for binary & ordinal logit and probit, (partial) generalized ordinal & multinomial logit models estimated with the glm(), clm() (in the 'ordinal' package), and vglm() (in the 'VGAM' package) functions. |
Depends: | R (≥ 3.5.0) |
License: | GPL-3 |
Encoding: | UTF-8 |
LazyData: | true |
NeedsCompilation: | no |
Packaged: | 2020-06-27 14:51:07 UTC; tfliao |
Repository: | CRAN |
Date/Publication: | 2020-06-27 15:00:06 UTC |
Graduate School Admissions Data of University Students
Description
This data set gives the graduate school admission status and university academic information of 400 students. “major” UCLA Institute for Digital Research and Education example data.
Usage
adm
Format
A dataframe containing 400 observations.
Source
read.csv("https://stats.idre.ucla.edu/stat/data/binary.csv")
Marginal Effects for a Variety of Logit and Probit Models
Description
This an R function for computing marginal effects for binary & ordinal logit and probit, (partial) generalized ordinal & multinomial logit models estimated with glm, clm (in ordinal), and vglm (in VGAM) commands. It returns a data frame with each column containing the predicted probabilities for a specific response y value given a set of chosen independent variable settings.
Usage
margEffects(model, specs, effect=1, method="logit")
Arguments
model |
An input model object estimated with glm, clm, or vglm. The order of the right-hand variables must be the same as that of the "specs" argument. |
specs |
A data frame with each row specifying the chosen values of all the independent variables in the model. |
effect |
default 1; an integer specifying the location of the marginal effects for an independent variable, with 1 being the one located in the first position. |
method |
Default "logit"; altenative methods are "probit" and "gologit". The "logit" and "probit" method can be estimated with glm or clm of the ordinal package while "mlogit" and "gologit" can be estimated with vglm in the VGAM package. For multinomial logit models, use the last choice as the reference category. |
Value
The function outputs a data frame of J number of columns, with each column containing the marginal effects on p(y=j) with j = 1, ..., J for ordinal models, j = 1, 0 for binary models, and j = 1, ..., Ref for multinomial models.. The rows are defined the same as in the input "specs" argument.
References
Tim F. Liao, 1994. Interpreting Probability Models: Logit, Probit, and Other Generalized Linear Models. Thousand Oaks, CA: Sage.
J. Scott Long, 1997. Regression Models for Categorical and Limited Dependent Variables. Thousand Oaks, CA: Sage.
Examples
data(adm)
adm$hRank[adm$rank==1 | adm$rank==2] <- 1
adm$hRank[adm$rank==3 | adm$rank==4] <- 0
logit1 <- glm(admit ~ gre + hRank + gpa, data=adm, binomial)
setval1 <- expand.grid(gre=seq(250,800,50), hRank=0:1, gpa=mean(adm$gpa))
margins1 <- margEffects(logit1, setval1)
probit1 <- glm(admit ~ gre + hRank + gpa, data=adm, binomial(link=probit))
margins2 <- margEffects(probit1, setval1, method="probit")
Predicted Probabilities for a Variety of Logit and Probit Models
Description
This an R function for computing predicted probabilities for binary & ordinal logit and probit, (partial) generalized ordinal & multinomial logit models estimated with glm, clm (in ordinal), and vglm (in VGAM) commands. It returns a data frame with each column containing the predicted probabilities for a specific response y value given a set of chosen independent variable settings.
Usage
predProbs(model, specs, method="logit")
Arguments
model |
An input model object estimated with glm, clm, or vglm. The order of the right-hand variables must be the same as that of the "specs" argument. |
specs |
A data frame with each row specifying the chosen values of all the independent variables in the model. |
method |
Default "logit"; altenative methods are "probit," "mlogit," and "gologit".The "logit" and "probit" method can be estimated with glm or clm of the ordinal package while "mlogit" and "gologit" can be estimated with vglm in the VGAM package. For multinomial logit models, use the last choice as the reference category. |
Value
The function outputs a data frame of J number of columns, with each column containing the predicted probabilities p(y=j) with j = 1, ..., J for ordinal models, j = 1, 0 for binary models, and j = 1, ..., Ref for multinomial models. The rows are defined the same as in the input "specs" argument.
References
Tim F. Liao, 1994. Interpreting Probability Models: Logit, Probit, and Other Generalized Linear Models. Thousand Oaks, CA: Sage.
J. Scott Long, 1997. Regression Models for Categorical and Limited Dependent Variables. Thousand Oaks, CA: Sage.
Examples
data(adm)
adm$hRank[adm$rank==1 | adm$rank==2] <- 1
adm$hRank[adm$rank==3 | adm$rank==4] <- 0
logit1 <- glm(admit ~ gre + hRank + gpa, data=adm, binomial)
setval1 <- expand.grid(gre=seq(250,800,50), hRank=0:1, gpa=mean(adm$gpa))
predprobs1 <- predProbs(logit1, setval1)
probit1 <- glm(admit ~ gre + hRank + gpa, data=adm, binomial(link=probit))
predprobs2 <- predProbs(probit1, setval1, method="probit")