"cem" is not a supported method - propensity-score-matching

auto.match <- matchit(formula = Same_Race_Latinx ~ PC_age + Salary_Beg_unadjusted_BASE, data=data2, method = "cem")
Same_Race_Latinx is the treatment (same race as principal) and a numeric variable 0/1
Salary_Beg_unadjusted_BASE continuous variable (salary)
This is not my full list of covariates but I cannot get any of it to run without getting this "Error: "cem" is not a supported method."
I don't even know where to start with fixing this..

This can simply be fixed by upgrading your version of MatchIt. If you were using MatchIt version 4.0.0, CEM was not supported. It is supported in more recent versions.

Related

Why am getting the following error when adjusting a glmm with the "glmmTMB" function and I try to obtain the confidence intervals?

I am trying to run the following model:
Mm3znb<-glmmTMB(total~ Geopolitical-1 + offset(logha) + YearCollected + tmn + (tmn|Site/Plot), ziformula = ~1, data = mc3m, family="nbinom2")
but when I try to obtain the confidence intervals am getting this error:
Error in dimnames(x) <- dn :
length of 'dimnames' [2] not equal to array extent
Does anyone know what this issue might be?
This is a problem that has been fixed very recently (June 2022) in the development version (confint wasn't working in models with more than one random effect; (tmn|Site/Plot) is implicitly two random effects, as it gets expanded to (tmn|Site) + (tmn|Site:Plot) internally).
If you can (you will need to install development tools - e.g. Xcode if you're on MacOS, Rtools if you're on Windows), install the development version via
remotes::install_github("glmmTMB/glmmTMB/glmmTMB")
The pkgdown page has a little more information about installing (if all else fails, contact the developers to see if they can make a recent binary package available).

Issue with GLMM in glmmTMB

I am trying to run the following model:
MP1 <- glmmTMB(Abundance ~ All_predator + Year + Location + Depth +
(1 | Site/Site.Transect),
data = plandat,
family = "poisson")
but am getting this error:
Error in .Call("getParameterOrder", data, parameters, new.env(),
PACKAGE = DLL) :
Incorrect number of arguments (3), expecting 4 for
'getParameterOrder'
Does anyone know what this issue might be?
This is a binary-incompatibility problem as documented here. You should probably have seen a "Package version inconsistency detected" message telling you to re-install glmmTMB from source. Depending on the release sequence of TMB and glmmTMB on CRAN, updating from CRAN as usual might work; otherwise you need to re-install from source (see ?glmmTMB::reinstalling).

R - Matchit - Propensity Score Matching - Discard function not working

I am using the MatchIt package on the LaLonde data-set and the discard argument is generating two types of errors. (The code works if I do not use the discard argument). In both cases, it is not clear how to resolve the problems....
The first issue is when I try discard = "hull.control"
m.opt1 <- matchit(treat ~ inc.re74 + inc.re75 + education + nonwhite +
age + nodegree, data = cps_controls, method = "optimal", ratio=1,
discard="hull.control")
This error message is produced....
Loading required namespace: WhatIf
Preprocessing data ...
Performing convex hull test ...
Error in mclapply(1:m, in_ch, mc.cores = mc.cores) :
'mc.cores' > 1 is not supported on Windows
The second issue is when I try discard = "control"
Error in d[i, ] <- abs(d1[i] - d0) :
number of items to replace is not a multiple of replacement length
Is there a way to address either of these? Thanks!!
Your issue seems to be kinda bug in MatchIt package as noted on SO here and here. I've submitted a ticket on GitHub.
Regarding the discard = "hull.control" issue:
Download the source code of MatchIt from here and edit discard.R. Add to the calls of WhatIf::whatif the argument mc.cores = 1. This should hard-code the number of cores used to 1 and thus eliminate the issue.
Uninstall the MatchIt package and build the new one by opening command line and type R CMD build C:\path\to\MatchIt-master. This should create a .tar.gz file. In R Studio, click on Tools -> Install packages... and select the local package.
You may need to restart R Studio if the library was loaded previously.
Enjoy.

Error message in lme4::glmer: " 'what' must be a character string or a function"

I am running a multi-level model. I use the following commands with validatedRS6 as the outcome, random as the predictor and clustno as the random effects variable.
new<-as.data.frame(read.delim("BABEX.dat", header=TRUE))
install.packages("lme4")
library(lme4)
model1<- glmer(validatedRS6 ~ random + (1|clustno), data=new, family=binomial("logit"), nAGQ = 1L)
However, I get the following error
Error in do.call(new, c(list(Class = "glmResp", family = family), ll[setdiff(names(ll), :
'what' must be a character string or a function
I have absolutely no idea what has gone wrong and have searched the internet. I am sorry but I cannot provide the data as it is from an intervention which has yet to be published.
(expanded from comment).
Congratulations, you found a bug in lme4! This is fixed now:
https://github.com/lme4/lme4/commit/9c12f002821f9567d5454e2ce3b78076dabffb54
It is caused by having a variable called new in the global environment (deep in the guts of the code, lme4 uses do.call(new,...) and finds your variable new rather than the built-in function new).
You can install a patched version from Github using devtools::install_github() (but you'll need compilation tools etc.). Alternately, there is a very simple workaround -- just call your variable anything other than new (you can't just copy it, i.e. new2 <- new -- you also have to make sure the old version is removed (rm("new"))).

stargazer() with Zelig regression output

I'm working with the R package stargazer. I have a Zelig model that I can't get stargazer to create Latex code for.
logit9.1 <- zelig(winner ~ treatment + count_parties + resp_OECD24 + DirExp + IndExp,
data = outcome, model = "logit" ,robust = TRUE)
stargazer(logit9.1)
Error in if (zelig.object$family$family == "gaussian") { :
argument is of length zero
If I change model="normal", I get the same error message. model="gaussian" is not a supported model in zelig(). The stargazer documentation says that it works with zelig objects.
stargazer v. 2.0 is now available on CRAN. The package has been updated to reflect changes made to Zelig objects, and has a bunch of other new features. Zelig has not always been perfect about backward compatibility of the object it creates, so the old version of stargazer() might have trouble. Perhaps you should try running your code with the latest version, and see if it works.

Resources