Title: | Computing Logit & Probit Predicted Probabilities & Marginal Effects |
---|---|
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. |
Authors: | Tim Liao |
Maintainer: | Tim Liao <[email protected]> |
License: | GPL-3 |
Version: | 1.0.1 |
Built: | 2025-02-28 05:16:35 UTC |
Source: | https://github.com/cran/ProbMarg |
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.
adm
adm
A dataframe containing 400 observations.
read.csv("https://stats.idre.ucla.edu/stat/data/binary.csv")
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.
margEffects(model, specs, effect=1, method="logit")
margEffects(model, specs, effect=1, method="logit")
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. |
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.
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.
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")
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")
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.
predProbs(model, specs, method="logit")
predProbs(model, specs, method="logit")
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. |
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.
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.
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")
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")