margins {oneinfl} | R Documentation |
Compute Marginal Effects for One-inflated models
Description
This wrapper function calls a different function to calculate marginal effects depending on the model type. The marginal effects of the variables are evaluated at specified points, such as the sample means or averages, or at custom-defined cases.
Usage
margins(model, df, at = "AE", verbose = TRUE)
Arguments
model |
An object representing a fitted model. Must be of class 'oneinflmodel' or 'truncmodel'. |
df |
A |
at |
A character string or list specifying where to evaluate the marginal effects:
|
verbose |
Logical; if |
Details
The function computes marginal effects for zero-truncated Poisson or negative binomial regression models. It handles different model types; 'oneinflmodel' for one-inflated models, and 'truncmodel' for standard count models. The marginal effects are evaluated at either all data points and averaged ('AE', the default), at the sample means of the variables ('EM'), or at a custom case. The marginal effects for dummy variables are actually the differences in expected outcomes for values of the dummy of 1 and 0. The marginal effects are displayed along with their statistical significance, evaluated based on the chosen 'at' parameter.
Value
If verbose=TRUE
(default), prints the marginal effects, their standard errors, z-values, p-values, and significance levels.
If verbose=FALSE
, returns a list containing the following components:
where
A description of how the marginal effects have been evaluated.
dEdq
The marginal effect. The partial derivative of the expected count with respect to a variable
q
in theX
and orZ
matrix, or the difference in expectation ifq
is binary.se
The standard errors of the marginal effects evaluated numerically and using a Jacobian via the delta method.
See Also
dEdq_nb
, dEdq_nb_noinfl
, dEdq_pois
,
dEdq_pois_noinfl
, model.frame
,
model.matrix
, numericDeriv
Examples
df <- data.frame(x = rnorm(100), z = rnorm(100), y = rpois(100, lambda = 5))
model <- oneinfl(y ~ x | z, df = df, dist = "Poisson")
margins(model, df, at = "AE") # Average Effect
margins(model, df, at = "EM", verbose=FALSE) # Effect at Means, suppress printing
margins(model, df, at = list(x = 1, z = 0)) # Custom case