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

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!

Related

Obtaining glmer coefficient confidence intervals via bootstrapping

I am in my first experience using mixed models in R for my statistical analysis. Due to my data being comprised of binary outcome variables, I have managed to build a logistic model using the glmer function of the lme4 package that I think works as I wanted it to.
I am now aiming to investigate the statistical significance of my model coefficients. I have read that generally, the best approach for generalized mixed models is to bootstrap confidence intervals, but I haven't managed to find a good, clear, explanation of how to do this in R.
Would anyone have any suggestions? Are there any packages in R that expedite this process, or do people generally build their own functions for this? I haven't really done any bootstrapping before so I'd appreciate some more in-depth answers.
If you want to compute parametric bootstrap confidence intervals, the built-in functionality
confint(fitted_model, method = "boot")
should work (see ?confint.merMod)
Also see this answer (which illustrates both parametric and nonparametric bootstrapping for user-defined quantities).
If you have multiple cores, you can speed this up by adding parallel = "multicore", ncpus = parallel::detectCores()-1 (or some other appropriate number of cores to use): see ?lme4::bootMer for details.

Calculate marginal effect for GLM (logistic) models in 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!

Is there any R package that makes tables of regression analysis like sjPlot?

I am very satisfied with the sjPlot package, with which I can make a table of results of regression analysis, such as lm(), lmer(), glm() and glmer().
However, I learned that the current version of sjt.lmer() in sjPlot does not support models without intercept so far (https://github.com/strengejacke/sjPlot/issues/78). I would like to make tables of results for the sake of my statistics learning.
I am wondering if you could let me know if there is any R package that makes regression tables like sjPlot. Thank you.

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.

Logistic Regression in R (SAS-like output)

I have a problem at hand which I'd think is fairly common amongst
groups were R is being adopted for Analytics in place of SAS.
Users would like to obtain results for logistic regression in R that
they have become accustomed to in SAS.
Towards this end, I was able to propose the Design package in R which
contains many functions to extract the various metrics that SAS
reports.
If you have suggestions pertaining to other packages, or sample code
that replicates some of the SAS outputs for logistic regression, I
would be glad to hear of them.
Some of the requirements are:
Stepwise variable selection for logistic regression
Choose base level for factor variables
The Hosmer-Lemeshow statistic
concordant and discordant
Tau C statistic
Thank you for your suggestions.
Just because SAS does it, doesn't necessarily mean it's good statistical practice. Step-wise regression is particularly problematic.
What I have found so far is that the Design and rms package to be the best (and only) package for these outputs.

Resources