Calculate predicted levels and marginal effects using the delta method to calculate standard errors. This is an R-based version of Stata’s ‘margins’ command.
Calculate predictive levels and margins for
ivreg objects (more models to be added - PRs welcome) using closed-form derivatives
Add custom variance-covariance matrices to all calculations to add, e.g., clustered or robust standard errors (for more information on replicating Stata analyses, see here)
Frequency weights are incorporated into margins and effects
To install this package from CRAN, please run
To install the development version of this package, please run
devtools::install_github('anniejw6/modmarg', build_vignettes = TRUE)
Here is an example of estimating predicted levels and effects using the
data(iris) mod <- glm(Sepal.Length ~ Sepal.Width + Species, data = iris, family = 'gaussian') # Predicted Levels modmarg::marg(mod, var_interest = 'Species', type = 'levels') # Predicted Effects modmarg::marg(mod, var_interest = 'Species', type = 'effects')
There are two vignettes included:
vignette('usage', package = 'modmarg') vignette('delta-method', package = 'modmarg')
The Delta method to estimate standard errors from a non-linear transformation from Econometrics by Simulation.
What is the intuition behind the sandwich estimator? from StackExchange
Least Squares Optimization by Harald E. Krogstad
The robust sandwich variance estimator for linear regression (theory) by Jonathan Bartlett