lme4

lme4 and languageR compatibility error: "input model is not a mer object”

依然范特西╮ 提交于 2019-12-03 13:48:50
问题 I have a dataset dat2 on which I want to fit a linear mixed-effects model. I used lmer() (package lme4) in the past in complement of pvals.fnc to compute the associated p-values. However, since I reinstalled R 3.0.2 version with the new lme4 (1.0.4) and languageR (1.4) packages I obtain an error about the output of lmer function. It says that the output is not a mer object. Indeed its class is lmeRmod. Here is the code I use: names(dat2)<-c("auc","subj","decod","soa","vis") attach(dat2) mod1

Plotting predicted values from lmer as a single plot

放肆的年华 提交于 2019-12-03 09:56:15
I am working on graphing the predicted values from a multilevel model (using the lme4 package). I am able to do this successfully using the Effect() function. As shown below: library(lme4) library(effects) m1=lmer(price~depth*cut+(1|cut),diamonds) plot(Effect(c("cut","depth"),m1)) But, I want to present these same data as a single plot with a legend. Using ggplots, I can do this; but, I lose the error bars, as shown below: ggplot(data.frame(Effect(c("cut","depth"),m1)), aes(x=depth,y=fit,color=cut,group=cut))+ geom_line() How can I recreate the first plot (with error bars) as a single plot?

How to have multiple groups in Python statsmodels linear mixed effects model?

半腔热情 提交于 2019-12-03 08:32:50
I am trying to use the Python statsmodels linear mixed effects model to fit a model that has two random intercepts, e.g. two groups. I cannot figure out how to initialize the model so that I can do this. Here's the example. I have data that looks like the following (taken from here ): subject gender scenario attitude frequency F1 F 1 pol 213.3 F1 F 1 inf 204.5 F1 F 2 pol 285.1 F1 F 2 inf 259.7 F1 F 3 pol 203.9 F1 F 3 inf 286.9 F1 F 4 pol 250.8 F1 F 4 inf 276.8 I want to make a linear mixed effects model with two random effects -- one for the subject group and one for the scenario group. I am

Any way to produce a LaTeX table from an lme4 mer model fit object?

不打扰是莪最后的温柔 提交于 2019-12-03 04:25:19
问题 Does anyone know a way to produce a nice publication quality LaTeX table from an lme4 mer object? Neither the xtable method (package xtable ) nor the latex method (package Hmisc ) know how to deal with mer objects. For example, given this fit: library(lme4) fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy) Are there any options for producing a nice LaTeX table of the coefficient estimates for both the fixed and random effects? EDIT: Because this is somewhat buried in the comment

warning messages when trying to run glmer in r

会有一股神秘感。 提交于 2019-12-03 03:55:01
问题 Dear Stack Overflow community, Currently I'm trying to rerun an old data analysis, binomial glmer model, (from early 2013) on the latest version of R and lme4, because I don't have the old versions of R and lme4 anymore. However, I experience similar warning messages as previous threads by dmartin and carine (first warning message) and other threads outside stack overflow (warnings 2 and 3). These warning messages didn't pop up on the earlier version of R and lme4 I used, so it must have

lme4 and languageR compatibility error: \"input model is not a mer object”

强颜欢笑 提交于 2019-12-03 03:38:41
I have a dataset dat2 on which I want to fit a linear mixed-effects model. I used lmer() (package lme4) in the past in complement of pvals.fnc to compute the associated p-values. However, since I reinstalled R 3.0.2 version with the new lme4 (1.0.4) and languageR (1.4) packages I obtain an error about the output of lmer function. It says that the output is not a mer object. Indeed its class is lmeRmod. Here is the code I use: names(dat2)<-c("auc","subj","decod","soa","vis") attach(dat2) mod1 <- lmer(auc ~ decod + (1 | subj)) mod2 <- lmer(auc ~ vis+ (1 | subj)) mod3 <- lmer(auc ~ decod + vis +

Extract random effect variances from lme4 mer model object

拟墨画扇 提交于 2019-12-03 03:32:49
问题 I have a mer object that has fixed and random effects. How do I extract the variance estimates for the random effects? Here is a simplified version of my question. study <- lmer(Reaction ~ Days + (1|Subject), data = sleepstudy) study This gives a long output - not too long in this case. Anyway, how do I explicitly select the Random effects: Groups Name Variance Std.Dev. Subject (Intercept) 1378.18 37.124 Residual 960.46 30.991 part of the output? I want the values themselves. I have taken

Multivariate Linear Mixed Model in lme4

陌路散爱 提交于 2019-12-03 03:19:11
问题 I wonder how to fit multivariate linear mixed model with lme4 . I fitted univariate linear mixed models with the following code: library(lme4) lmer.m1 <- lmer(Y1~A*B+(1|Block)+(1|Block:A), data=Data) summary(lmer.m1) anova(lmer.m1) lmer.m2 <- lmer(Y2~A*B+(1|Block)+(1|Block:A), data=Data) summary(lmer.m2) anova(lmer.m2) I'd like to know how to fit multivariate linear mixed model with lme4 . The data is below: Block A B Y1 Y2 1 1 1 135.8 121.6 1 1 2 149.4 142.5 1 1 3 155.4 145.0 1 2 1 105.9 106

How to compare a model with no random effects to a model with a random effect using lme4?

时光怂恿深爱的人放手 提交于 2019-12-02 19:21:06
I can use gls() from the nlme package to build mod1 with no random effects. I can then compare mod1 using AIC to mod2 built using lme() which does include a random effect. mod1 = gls(response ~ fixed1 + fixed2, method="REML", data) mod2 = lme(response ~ fixed1 + fixed2, random = ~1 | random1, method="REML",data) AIC(mod1,mod2) Is there something similar to gls() for the lme4 package which would allow me to build mod3 with no random effects and compare it to mod4 built using lmer() which does include a random effect? mod3 = ???(response ~ fixed1 + fixed2, REML=T, data) mod4 = lmer(response ~

Any way to produce a LaTeX table from an lme4 mer model fit object?

那年仲夏 提交于 2019-12-02 18:43:12
Does anyone know a way to produce a nice publication quality LaTeX table from an lme4 mer object? Neither the xtable method (package xtable ) nor the latex method (package Hmisc ) know how to deal with mer objects. For example, given this fit: library(lme4) fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy) Are there any options for producing a nice LaTeX table of the coefficient estimates for both the fixed and random effects? EDIT: Because this is somewhat buried in the comment threads below, note that a community wiki is in development for R LaTeX tables: Tools for making latex