I am doing model averaging with MuMIn and trying to interpret the results.
Everything works fine, but I am wondering about the names of my coefficients in the results:
Model-averaged coefficients:
(full average)
Estimate Std. Error Adjusted SE
cond((Int)) 0.9552775 0.0967964 0.0969705
cond(Distanzpunkt) -0.0001217 0.0001451 0.0001453
cond(area_km2) 0.0022712 0.0030379 0.0030422
cond(prop) 0.0487036 0.1058994 0.1060808
Does someone know, what "cond()" tells me and why it appears in the model output?
Within the models, the coefficients are named "Distanzpunkt", "area_km2" and "prop".
Were you fitting a zero inflation model with glmmTMB? If so, then cond() is referring to the terms in the conditional model, rather than the zero-inflation model.
Related
I am trying to estimate confidence intervals for a mixed effects poisson model using robust standard errors in R. I followed these instructions and was able to estimate confidence intervals for a model without random effects.
Now, I would like to estimate confidence intervals with robust standard errors for a poisson model, with a random term. It seems like the sandwich command does not work for glmer, only glm. I have not been able to find a good solution yet. Any suggestions?
I want to report the results of an one factorial lme from the nlme package. I want to know the overall effect of A on y. To do so I would compare the model with a Null model:
m1 <- lme(y~A,random=~1|B/C,data=data,weights=varIdent(form = ~1|A),method="ML")
m0 <- lme(y~1,random=~1|B/C,data=data,weights=varIdent(form = ~1|A),method="ML")
I am using maximum likelihood because I am comparing models with different main effects.
stats::anova(m0,m1) gives me a significant p value, meaning that there is a significant effect of A on y. However, in contrast to lmer models made with lme4, no Chi2 values are given. First: Is this approach valid? And second: What is the best way to report the result?
Thanks for your answers
An anova with lme should give you the same information as with lmer. Both use what's called a deviance test or likelihood ratio test. The L.ratio part in the table returned by anova is simply the difference in the loglikelihood of the two models multiplied by -2. A deviance test tests this value against a Chi2 distribution with the difference in model parameters (in your case 1) degrees of freedom. So the value reported under L.ratio for lme models is the same as the Chi2 value reported for lmer models (assuming the models are the same of course, and lmer rounds the value to a decimal).
The approach is valid and you could report the value under L.ratio along with the degrees of freedom and p-value, but I would add more information in your report such as the fixed and random coefficients of both models and other parameters that you've added (such as the difference in variance for levels of A specified under weights). If you're only interested in the fixed effect of A than a Wald test should also be appropriate though REML estimates are recommended in cases with a small number of groups (Snijders & Bosker, 2012). The test statistic is the t-value and associated p-value in the model summary output summary(m1). Chapter 6 in Snijders & Bosker (2012) gives a great explanation on tests for fixed and random parameters. Along with reporting examples.
I employed a random-effects plm model (from package plm) to estimate my coefficients and I used the vcovHC in order to correct for heteroskedasticity.
However, how can I correct for autocorrelation as well? Should I use vcovNW or vcovSCC? because I tried with the vcovHC Arellano but, as it would be expected, I obtain the same results as by using only vcovHC.
How can I take the residuals autocorrelation into account in such a model?
Why is not confint.default which is based on asymptotic normality doesn't work for lmer model ?
fit <- lmer(y~(1|operator)+(1|part),data=dat)
Linear mixed model fit by REML ['lmerMod']
Formula: y ~ (1 | operator) + (1 | part)
Data: dat
REML criterion at convergence: 409.3913
Random effects:
Groups Name Std.Dev.
part (Intercept) 3.2018
operator (Intercept) 0.1031
Residual 0.9398
Number of obs: 120, groups: part, 20; operator, 3
Fixed Effects:
(Intercept)
22.39
confint.default(fit)
Error in as.integer(x) :
cannot coerce type 'S4' to vector of type 'integer'
What is the error saying ? How can I get confidence interval based on asymptotic normality for lmer model ?
Don't use confint.default(), just use confint(). The methods to calculate confidence intervals are different for the different model types. You can see the different methods with methods(confint). The "correct" version of the function is called based on the class of the first object you pass to the function. Directly calling one of the methods usually isn't a good idea.
There are options for how to calculate the bounds for the lmer objects. Look at the help page for ?confint.merMod to see the options unique to that model type.
#MrFlick is correct, but it may be worth adding that confint.merMod() gives likelihood profile CIs by default; confint(.,method="Wald") will give the confidence intervals based on asymptotic normality:
β"Wald"β: approximating the confidence intervals (of fixed-effect
parameters only; all variance-covariance parameters CIs will
be returned as βNAβ) based on the estimated local curvature
of the likelihood surface;
(this is obvious from the help page, but is probably worth restating here).
I am trying to estimate some spatial models in R using the data from a paper on spatial econometric models using cross-section time series data by Franzese & Hays (2007).
I focus on their results given in table 4 (see below).
Using lm I am able to replicate their results for the OLS, S-OLS, and S-2SLS models.
However, in trying to estimate the S-ML (Spatial Maximum Likelihood) model I run into trouble.
If I use a GLM model there are some minor differences for some of the explanatory variables but there is quite a large margin with regard to the estimated coefficient for the spatial lag (output shown below).
I'm not entirely sure about why GLM is not the right estimation method in this case.
Using GLS I get results similar to GLM (possibly related).
require(MASS)
m4<-glm(lnlmtue~lnlmtue_1+SpatLag+DENSITY+DEIND+lngdp_pc+UR+TRADE+FDI+LLVOTE+LEFTC+TCDEMC+GOVCON+OLDAGE+factor(cc)+factor(year),family=gaussian,data=fh)
summary(m4)
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 7.199091355 3.924227850 1.835 0.068684 .
lnlmtue_1 0.435487985 0.080844033 5.387 0.000000293 ***
SpatLag -0.437680018 0.101078950 -4.330 0.000028105 ***
DENSITY 0.007633016 0.010268468 0.743 0.458510
DEIND 0.040270153 0.032304496 1.247 0.214618
I tried using the splm package but this leads to even larger consistencies (output shown below).
Moreover, I'm not able to include fixed effects in the model.
require(splm)
m4a<-spml(lnlmtue~lnlmtue_1+DENSITY+DEIND+lngdp_pc+UR+TRADE+FDI+LLVOTE+LEFTC+ TCDEMC+GOVCON+OLDAGE,data=fh,index=c("cc","year"),listw=mat2listw(wmat),
model="pooling",spatial.error="none",lag=T)
summary(m4a)
Coefficients:
Estimate Std. Error t-value Pr(>|t|)
(Intercept) 1.79439070 0.78042284 2.2993 0.02149 *
lnlmtue_1 0.75795987 0.04828145 15.6988 < 2e-16 ***
DENSITY -0.00026038 0.00203002 -0.1283 0.89794
DEIND -0.00489516 0.01414457 -0.3461 0.72928
So basically my question really is how does one properly estimate a SAR model with cross-section time-series data in R?
R-code
Replication data
Adjacency matrix
Is it critical that you use R?
I suggest that you examine the features of Geoda, a free spatial analysis package available from Arizona State University.
Though I have only used it to run basic spatial OLS (not 2SLS), I was pleased with Geoda's flexibility and visualization tools. I encourage you to skim the documentation and consider downloading the latest release.
If you must use R, I suggest exploring the GeoXp package (http://cran.r-project.org/web/packages/GeoXp/index.html).