Title: | Marginal Effects, Odds Ratios and Incidence Rate Ratios for GLMs |
---|---|
Description: | Estimates probit, logit, Poisson, negative binomial, and beta regression models, returning their marginal effects, odds ratios, or incidence rate ratios as an output. Greene (2008, pp. 780-7) provides a textbook introduction to this topic. |
Authors: | Alan Fernihough [aut, cre], Arne Henningsen [ctb] |
Maintainer: | Alan Fernihough <[email protected]> |
License: | GPL-2 | GPL-3 |
Version: | 1.2-2 |
Built: | 2024-10-26 06:26:19 UTC |
Source: | CRAN |
This function estimates a beta regression model and calculates the corresponding marginal effects.
betamfx(formula, data, atmean = TRUE, robust = FALSE, clustervar1 = NULL, clustervar2 = NULL, control = betareg.control(), link.phi = NULL, type = "ML")
betamfx(formula, data, atmean = TRUE, robust = FALSE, clustervar1 = NULL, clustervar2 = NULL, control = betareg.control(), link.phi = NULL, type = "ML")
formula |
an object of class “formula” (or one that can be coerced to that class). |
data |
the data frame containing these data. This argument must be used. |
atmean |
default marginal effects represent the partial effects for the average observation.
If |
robust |
if |
clustervar1 |
a character value naming the first cluster on which to adjust the standard errors. |
clustervar2 |
a character value naming the second cluster on which to adjust the standard errors for two-way clustering. |
control |
a list of control arguments specified via |
link.phi |
as in the |
type |
as in the |
The underlying link function in the mean model (mu) is “logit”. If both robust=TRUE
and
!is.null(clustervar1)
the function overrides the robust
command and computes clustered
standard errors.
mfxest |
a coefficient matrix with columns containing the estimates, associated standard errors, test statistics and p-values. |
fit |
the fitted |
dcvar |
a character vector containing the variable names where the marginal effect refers to the impact of a discrete change on the outcome. For example, a factor variable. |
call |
the matched call. |
Francisco Cribari-Neto, Achim Zeileis (2010). Beta Regression in R. Journal of Statistical Software 34(2), 1-24.
Bettina Gruen, Ioannis Kosmidis, Achim Zeileis (2012). Extended Beta Regression in R: Shaken, Stirred, Mixed, and Partitioned. Journal of Statistical Software, 48(11), 1-25.
# simulate some data set.seed(12345) n = 1000 x = rnorm(n) # beta outcome y = rbeta(n, shape1 = plogis(1 + 0.5 * x), shape2 = (abs(0.2*x))) # use Smithson and Verkuilen correction y = (y*(n-1)+0.5)/n data = data.frame(y,x) betamfx(y~x|x, data=data)
# simulate some data set.seed(12345) n = 1000 x = rnorm(n) # beta outcome y = rbeta(n, shape1 = plogis(1 + 0.5 * x), shape2 = (abs(0.2*x))) # use Smithson and Verkuilen correction y = (y*(n-1)+0.5)/n data = data.frame(y,x) betamfx(y~x|x, data=data)
This function estimates a beta regression model and calculates the corresponding odds ratios.
betaor(formula, data, robust = FALSE, clustervar1 = NULL, clustervar2 = NULL, control = betareg.control(), link.phi = NULL, type = "ML")
betaor(formula, data, robust = FALSE, clustervar1 = NULL, clustervar2 = NULL, control = betareg.control(), link.phi = NULL, type = "ML")
formula |
an object of class “formula” (or one that can be coerced to that class). |
data |
the data frame containing these data. This argument must be used. |
robust |
if |
clustervar1 |
a character value naming the first cluster on which to adjust the standard errors. |
clustervar2 |
a character value naming the second cluster on which to adjust the standard errors for two-way clustering. |
control |
a list of control arguments specified via |
link.phi |
as in the |
type |
as in the |
The underlying link function in the mean model (mu) is "logit". If both robust=TRUE
and
!is.null(clustervar1)
the function overrides the robust
command and computes clustered
standard errors.
oddsratio |
a coefficient matrix with columns containing the estimates, associated standard errors, test statistics and p-values. |
fit |
the fitted |
call |
the matched call. |
Francisco Cribari-Neto, Achim Zeileis (2010). Beta Regression in R. Journal of Statistical Software 34(2), 1-24.
Bettina Gruen, Ioannis Kosmidis, Achim Zeileis (2012). Extended Beta Regression in R: Shaken, Stirred, Mixed, and Partitioned. Journal of Statistical Software, 48(11), 1-25.
# simulate some data set.seed(12345) n = 1000 x = rnorm(n) # beta outcome y = rbeta(n, shape1 = plogis(1 + 0.5 * x), shape2 = (abs(0.2*x))) # use Smithson and Verkuilen correction y = (y*(n-1)+0.5)/n data = data.frame(y,x) betaor(y~x|x, data=data)
# simulate some data set.seed(12345) n = 1000 x = rnorm(n) # beta outcome y = rbeta(n, shape1 = plogis(1 + 0.5 * x), shape2 = (abs(0.2*x))) # use Smithson and Verkuilen correction y = (y*(n-1)+0.5)/n data = data.frame(y,x) betaor(y~x|x, data=data)
This function estimates a binary logistic regression model and calculates the corresponding marginal effects.
logitmfx(formula, data, atmean = TRUE, robust = FALSE, clustervar1 = NULL, clustervar2 = NULL, start = NULL, control = list())
logitmfx(formula, data, atmean = TRUE, robust = FALSE, clustervar1 = NULL, clustervar2 = NULL, start = NULL, control = list())
formula |
an object of class “formula” (or one that can be coerced to that class). |
data |
the data frame containing these data. This argument must be used. |
atmean |
default marginal effects represent the partial effects for the average observation.
If |
robust |
if |
clustervar1 |
a character value naming the first cluster on which to adjust the standard errors. |
clustervar2 |
a character value naming the second cluster on which to adjust the standard errors for two-way clustering. |
start |
starting values for the parameters in the |
control |
see |
If both robust=TRUE
and !is.null(clustervar1)
the function overrides the robust
command and computes clustered standard errors.
mfxest |
a coefficient matrix with columns containing the estimates, associated standard errors, test statistics and p-values. |
fit |
the fitted |
dcvar |
a character vector containing the variable names where the marginal effect refers to the impact of a discrete change on the outcome. For example, a factor variable. |
call |
the matched call. |
William H. Greene (2008). Econometric Analysis (6th ed.). Prentice Hall, N.Y. pp 770-787.
# simulate some data set.seed(12345) n = 1000 x = rnorm(n) # binary outcome y = ifelse(pnorm(1 + 0.5*x + rnorm(n))>0.5, 1, 0) data = data.frame(y,x) logitmfx(formula=y~x, data=data)
# simulate some data set.seed(12345) n = 1000 x = rnorm(n) # binary outcome y = ifelse(pnorm(1 + 0.5*x + rnorm(n))>0.5, 1, 0) data = data.frame(y,x) logitmfx(formula=y~x, data=data)
This function estimates a binary logistic regression model and calculates the corresponding odds ratios.
logitor(formula, data, robust = FALSE, clustervar1 = NULL, clustervar2 = NULL, start = NULL, control = list())
logitor(formula, data, robust = FALSE, clustervar1 = NULL, clustervar2 = NULL, start = NULL, control = list())
formula |
an object of class “formula” (or one that can be coerced to that class). |
data |
the data frame containing these data. This argument must be used. |
robust |
if |
clustervar1 |
a character value naming the first cluster on which to adjust the standard errors. |
clustervar2 |
a character value naming the second cluster on which to adjust the standard errors for two-way clustering. |
start |
starting values for the parameters in the |
control |
see |
If both robust=TRUE
and !is.null(clustervar1)
the function overrides the robust
command and computes clustered standard errors.
oddsratio |
a coefficient matrix with columns containing the estimates, associated standard errors, test statistics and p-values. |
fit |
the fitted |
call |
the matched call. |
# simulate some data set.seed(12345) n = 1000 x = rnorm(n) # binary outcome y = ifelse(pnorm(1 + 0.5*x + rnorm(n))>0.5, 1, 0) data = data.frame(y,x) logitor(formula=y~x, data=data)
# simulate some data set.seed(12345) n = 1000 x = rnorm(n) # binary outcome y = ifelse(pnorm(1 + 0.5*x + rnorm(n))>0.5, 1, 0) data = data.frame(y,x) logitor(formula=y~x, data=data)
This function estimates a negative binomial regression model and calculates the corresponding incidence rate ratios.
negbinirr(formula, data, robust = FALSE, clustervar1 = NULL, clustervar2 = NULL, start = NULL, control = glm.control())
negbinirr(formula, data, robust = FALSE, clustervar1 = NULL, clustervar2 = NULL, start = NULL, control = glm.control())
formula |
an object of class “formula” (or one that can be coerced to that class). |
data |
the data frame containing these data. This argument must be used. |
robust |
if |
clustervar1 |
a character value naming the first cluster on which to adjust the standard errors. |
clustervar2 |
a character value naming the second cluster on which to adjust the standard errors for two-way clustering. |
start |
starting values for the parameters in the |
control |
see |
If both robust=TRUE
and !is.null(clustervar1)
the function overrides the robust
command and computes clustered standard errors.
irr |
a coefficient matrix with columns containing the estimates, associated standard errors, test statistics and p-values. |
fit |
the fitted |
call |
the matched call. |
# simulate some data set.seed(12345) n = 1000 x = rnorm(n) y = rnegbin(n, mu = exp(1 + 0.5 * x), theta = 0.5) data = data.frame(y,x) negbinirr(formula=y~x,data=data)
# simulate some data set.seed(12345) n = 1000 x = rnorm(n) y = rnegbin(n, mu = exp(1 + 0.5 * x), theta = 0.5) data = data.frame(y,x) negbinirr(formula=y~x,data=data)
This function estimates a negative binomial regression model and calculates the corresponding marginal effects.
negbinmfx(formula, data, atmean = TRUE, robust = FALSE, clustervar1 = NULL, clustervar2 = NULL, start = NULL, control = glm.control())
negbinmfx(formula, data, atmean = TRUE, robust = FALSE, clustervar1 = NULL, clustervar2 = NULL, start = NULL, control = glm.control())
formula |
an object of class “formula” (or one that can be coerced to that class). |
data |
the data frame containing these data. This argument must be used. |
atmean |
default marginal effects represent the partial effects for the average observation.
If |
robust |
if |
clustervar1 |
a character value naming the first cluster on which to adjust the standard errors. |
clustervar2 |
a character value naming the second cluster on which to adjust the standard errors for two-way clustering. |
start |
starting values for the parameters in the |
control |
see |
If both robust=TRUE
and !is.null(clustervar1)
the function overrides the robust
command and computes clustered standard errors.
mfxest |
a coefficient matrix with columns containing the estimates, associated standard errors, test statistics and p-values. |
fit |
the fitted |
dcvar |
a character vector containing the variable names where the marginal effect refers to the impact of a discrete change on the outcome. For example, a factor variable. |
call |
the matched call. |
# simulate some data set.seed(12345) n = 1000 x = rnorm(n) y = rnegbin(n, mu = exp(1 + 0.5 * x), theta = 0.5) data = data.frame(y,x) negbinmfx(formula=y~x,data=data)
# simulate some data set.seed(12345) n = 1000 x = rnorm(n) y = rnegbin(n, mu = exp(1 + 0.5 * x), theta = 0.5) data = data.frame(y,x) negbinmfx(formula=y~x,data=data)
This function estimates a negative binomial regression model and calculates the corresponding incidence rate ratios.
poissonirr(formula, data, robust = FALSE, clustervar1 = NULL, clustervar2 = NULL, start = NULL, control = list())
poissonirr(formula, data, robust = FALSE, clustervar1 = NULL, clustervar2 = NULL, start = NULL, control = list())
formula |
an object of class “formula” (or one that can be coerced to that class). |
data |
the data frame containing these data. This argument must be used. |
robust |
if |
clustervar1 |
a character value naming the first cluster on which to adjust the standard errors. |
clustervar2 |
a character value naming the second cluster on which to adjust the standard errors for two-way clustering. |
start |
starting values for the parameters in the |
control |
see |
If both robust=TRUE
and !is.null(clustervar1)
the function overrides the robust
command and computes clustered standard errors.
irr |
a coefficient matrix with columns containing the estimates, associated standard errors, test statistics and p-values. |
fit |
the fitted |
call |
the matched call. |
# simulate some data set.seed(12345) n = 1000 x = rnorm(n) y = rnegbin(n, mu = exp(1 + 0.5 * x), theta = 0.5) data = data.frame(y,x) poissonirr(formula=y~x,data=data)
# simulate some data set.seed(12345) n = 1000 x = rnorm(n) y = rnegbin(n, mu = exp(1 + 0.5 * x), theta = 0.5) data = data.frame(y,x) poissonirr(formula=y~x,data=data)
This function estimates a Poisson regression model and calculates the corresponding marginal effects.
poissonmfx(formula, data, atmean = TRUE, robust = FALSE, clustervar1 = NULL, clustervar2 = NULL, start = NULL, control = list())
poissonmfx(formula, data, atmean = TRUE, robust = FALSE, clustervar1 = NULL, clustervar2 = NULL, start = NULL, control = list())
formula |
an object of class “formula” (or one that can be coerced to that class). |
data |
the data frame containing these data. This argument must be used. |
atmean |
default marginal effects represent the partial effects for the average observation.
If |
robust |
if |
clustervar1 |
a character value naming the first cluster on which to adjust the standard errors. |
clustervar2 |
a character value naming the second cluster on which to adjust the standard errors for two-way clustering. |
start |
starting values for the parameters in the |
control |
see |
If both robust=TRUE
and !is.null(clustervar1)
the function overrides the robust
command and computes clustered standard errors.
mfxest |
a coefficient matrix with columns containing the estimates, associated standard errors, test statistics and p-values. |
fit |
the fitted |
dcvar |
a character vector containing the variable names where the marginal effect refers to the impact of a discrete change on the outcome. For example, a factor variable. |
call |
the matched call. |
# simulate some data set.seed(12345) n = 1000 x = rnorm(n) y = rnegbin(n, mu = exp(1 + 0.5 * x), theta = 0.5) data = data.frame(y,x) poissonmfx(formula=y~x,data=data)
# simulate some data set.seed(12345) n = 1000 x = rnorm(n) y = rnegbin(n, mu = exp(1 + 0.5 * x), theta = 0.5) data = data.frame(y,x) poissonmfx(formula=y~x,data=data)
This function estimates a probit regression model and calculates the corresponding marginal effects.
probitmfx(formula, data, atmean = TRUE, robust = FALSE, clustervar1 = NULL, clustervar2 = NULL, start = NULL, control = list())
probitmfx(formula, data, atmean = TRUE, robust = FALSE, clustervar1 = NULL, clustervar2 = NULL, start = NULL, control = list())
formula |
an object of class “formula” (or one that can be coerced to that class). |
data |
the data frame containing these data. This argument must be used. |
atmean |
default marginal effects represent the partial effects for the average observation.
If |
robust |
if |
clustervar1 |
a character value naming the first cluster on which to adjust the standard errors. |
clustervar2 |
a character value naming the second cluster on which to adjust the standard errors for two-way clustering. |
start |
starting values for the parameters in the |
control |
see |
If both robust=TRUE
and !is.null(clustervar1)
the function overrides the robust
command and computes clustered standard errors.
mfxest |
a coefficient matrix with columns containing the estimates, associated standard errors, test statistics and p-values. |
fit |
the fitted |
dcvar |
a character vector containing the variable names where the marginal effect refers to the impact of a discrete change on the outcome. For example, a factor variable. |
call |
the matched call. |
William H. Greene (2008). Econometric Analysis (6th ed.). Prentice Hall, N.Y. pp 770-787.
# simulate some data set.seed(12345) n = 1000 x = rnorm(n) # binary outcome y = ifelse(pnorm(1 + 0.5*x + rnorm(n))>0.5, 1, 0) data = data.frame(y,x) probitmfx(formula=y~x, data=data)
# simulate some data set.seed(12345) n = 1000 x = rnorm(n) # binary outcome y = ifelse(pnorm(1 + 0.5*x + rnorm(n))>0.5, 1, 0) data = data.frame(y,x) probitmfx(formula=y~x, data=data)