Calculate marginal effect for GLM (logistic) models in R - r

I came across 2 packages to calculate marginal effect for a logistic regression model in R with some interaction terms.
margins package https://cran.r-project.org/web/packages/margins/vignettes/Introduction.html
and mfx pacakge https://cran.r-project.org/web/packages/mfx/mfx.pdf
I want to calculate the average marginal effect and don't know which package is appropriate. For some reason, I cannot use the first one. So I have tried
install.packages("margins-package")
library(margins) ## Library not found
margins(logit) ## Logit is my glm model but that function is not found
The author of the margins package criticised mfx package and other packages used to calculate marginal effect as they do not account for interaction term properly. Does anyone have experience with one of the packages or both? I'd like to hear your feedback.
Thank you!

Related

Validation for multivariate autoregressive model (MAR) with MAR1 package

I'm trying to validation test or to test reliability of multivariate autoregressive model estimated by MAR1 package.
As far as I understand, there is no such function in this package.
As one of the solution, I tried to use "plot(model,. plot/.type=model.resids.ytT)", which is introduced in users guideline of MARSS package, to confirm whether the model has convergence problems.
However, the output plot was the same as the plot of coefficients obtained by the function "plot(model$top.benefit)".
We would appreciate it if you could tell us the best way to do this.
Sincerely,

R - Meta-Analysis - How to create a forest plot with robust estimates from clubSandwich functions

I have a quick question about displaying robust estimates in a forest plot.
I am using rma.mv() from the metafor package to fit a multilevel random-effects model. For robust estimates, I use the conf_int() and coef_test() functions from the clubSandwich package. However, the forest() function from metafor only accepts objects of class rma, which are not produced by the functions for robust estimates.
Is there any way to use the forest() function to create a nice forest plot, but somehow integrate the robust overall estimate from the clubSandwich functions?
Appreciate any advice or alternative solutions!
You can use forest() to plot the individual estimates and then addpoly() to add the polygon. For the latter, you just need to pull out the pooled estimate and corresponding standard error from the object returned by coef_test().

How to calculate marginal effects for plm models

I wish to obtain marginal effects for covariates that are in my plm models in first differences with interacted variables. For my lm and glm models I am using the margins package and its functions. However, this method does not seem to work with panel models.
What alternatives do I have?
Thank you.
EDIT:
In the absence of any viable solution I would calculate by hand the marginal effects at specific values of the relevant covariables. Ideally I would like to do so in a faster way.

Probability plots for logistic regression estimated with survey/svyglm including polynoms

I'm trying to visualize a second-order polynomial in a logistic regression model estimated with the svyglm command in R's survey package to account for survey weights. In particular, I'm searching for conditional effect and probability plots. However, all attempts seem to fail. So far I tried functions from the packages sjPlot, margins, jtools and interplot as well as using I(var^2) and polynom(var, 2, raw=TRUE). Package documentations don't provide much help on the survey::svyglm-issue. Any hints at useful packages as well as correct syntax specifications for the packages mentioned above are highly appreciated!

Random Effects with count Models

I'm trying to do a hurdle model with random effects in either r or stata. I've looked at the glmmADMB package, but am running into problems getting it download in R and I can't find any documentation on the package in Cran. Is this package still available? Has anyone used it successfully to estimate a hurdle model with random effects?
Alternatively, is there a way to estimate this in stata? Is there a way to estimate random effects with any type of count data in stata?
Any advice would be greatly appreciated.
Jennifer
In Stata, xtnbreg and xtpoisson have the random effects estimator as the default option. You can always estimate the two parts separately by hand. See the count-data chapter of Cameron and Trivedi's Stata book for cross-sectional examples.
You also have the user-written hplogit and hnlogit for hurdle count models. These use a logit/probit for the first-stage and a zero-truncated poisson/negative binomial for the second stage. Also, a finite mixture model might be a nice approach (see user-written fmm). There's also ztpnm. All these are cross-sectional models.

Resources