lme4

lmerTest::anova not showing p-values

倾然丶 夕夏残阳落幕 提交于 2019-12-08 13:15:10
问题 I am asking a new question because the dublicate (anova() does not display p-value when used with lmerTest) is not really providing an answer: I ran into the same problem that lmerTest::anova will not output degrees of freedom and p-values for a specific model (that is much less complicated than the one in the post mentioned above): DirectionFit <- lmer(Similarity ~ picture_category * ComparisonType + (1 + picture_category + ComparisonType|Subject), data = DirectionData, REML=FALSE) I noticed

Confidence interval of random effects with lmer

大兔子大兔子 提交于 2019-12-08 13:15:09
问题 I am using lmer from lme4 package to calculate confidence interval for variance component . When I fit the model there is warning messages : fit <- lmer(Y~X+Z+X:Z+(X|group),data=sim_data) Warning messages: 1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : unable to evaluate scaled gradient 2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model failed to converge: degenerate Hessian with 1 negative eigenvalues I searched a lot to understand why

Variable lengths differ in R (linear modelling with lme4)

这一生的挚爱 提交于 2019-12-08 08:10:44
问题 My input file: Treat1 Treat2 Batch gene1 gene2 High Low 1 92.73 4.00 Low Low 1 101.85 6.00 High High 1 136.00 4.00 Low High 1 104.00 3.00 High Low 2 308.32 10.00 Low Low 2 118.93 3.00 High High 2 144.47 3.00 Low High 2 189.66 4.00 High Low 3 95.12 2.00 Low Low 3 72.08 6.00 High High 3 108.65 2.00 Low High 3 75.00 3.00 High Low 4 111.39 5.00 Low Low 4 119.80 4.00 High High 4 466.55 11.00 Low High 4 125.00 3.00 There are tens of thousands of additional columns, each with a header and a list of

Prediction in R - GLMM

霸气de小男生 提交于 2019-12-07 17:24:47
问题 When we use a traditional logistic regression and make a prediction in R, for example: library(dplyr) n = 300 xx<-c("r1","r2","r3","r4","r5") xxx<-c("e1","e2","e3") p=0.3 df1 <- data_frame( xx1 = runif(n, min = 0, max = 10), xx2 = runif(n, min = 0, max = 10), xx3 = runif(n, min = 0, max = 10), School = factor(sample(xxx, n,re=TRUE)), Rank = factor(sample(xx, n,re=TRUE)), yx = as.factor(rbinom(n, size = 1, prob = p)) ) df1 mm<-glm(yx ~ xx1 + xx2 + xx3 + School + Rank,binomial,df1) n11 = data

Variable lengths differ in R (linear modelling with lme4)

对着背影说爱祢 提交于 2019-12-07 16:03:29
My input file: Treat1 Treat2 Batch gene1 gene2 High Low 1 92.73 4.00 Low Low 1 101.85 6.00 High High 1 136.00 4.00 Low High 1 104.00 3.00 High Low 2 308.32 10.00 Low Low 2 118.93 3.00 High High 2 144.47 3.00 Low High 2 189.66 4.00 High Low 3 95.12 2.00 Low Low 3 72.08 6.00 High High 3 108.65 2.00 Low High 3 75.00 3.00 High Low 4 111.39 5.00 Low Low 4 119.80 4.00 High High 4 466.55 11.00 Low High 4 125.00 3.00 There are tens of thousands of additional columns, each with a header and a list of numbers, same length as "gene1" column. My code: library(lme4) library(lmerTest) # Import the data.

Having issues using the lme4 predict function on my mixed models

二次信任 提交于 2019-12-07 06:09:31
问题 I’m having a bit of a struggle trying to use the lme4 predict function on my mixed models. When making predications I want to be able to set some of my explanatory variables to a specified level but average across others. Here’s some made up data that is a simplified, nonsense version of my original dataset: a <- data.frame( TLR4=factor(rep(1:3, each=4, times=4)), repro.state=factor(rep(c("a","j"),each=6,times=8)), month=factor(rep(1:2,each=8,times=6)), sex=factor(rep(1:2, each=4, times=12)),

Frequency weights in R (multilevel using lme4)

白昼怎懂夜的黑 提交于 2019-12-06 12:25:03
问题 I'm building a multilevel model with lme4 (two levels: a class and a student level with educational data). I'm using the ICCS 2009 data: http://www.iea.nl/iccs_2009.html). ICCS 2009 advise the use weights. I made a “within-school student weight” as the product of the class and student level weight factors. I also made the sums of the weights equal to the sample size. My question: how can I specify in R that I want to use this weight as a frequency weight. Do I have to use the "survey" package

Plotting results of lme4 with ggplot2

拥有回忆 提交于 2019-12-06 12:06:58
问题 I used lme4 for a linear mixed-effects model lme.m1 <- lmer(I1 ~ P1 + Period * Actor + (1 | Actor), data=Q) There are 8 Actors and I have three Periods. Now I would like to plot (using ggplot2) the different lines in 8 different facets (which does not seem to be difficult). However, I do not know how to draw three different lines (because of the three different periods) for each actor in the same facet. I used the following code from http://www.sagepub.com/long/chapters/rcode/82689_10rc.txt:

glmer model from early 2013: warning message about convergence when re-running it

坚强是说给别人听的谎言 提交于 2019-12-06 08:58:06
问题 More than 1 year ago (Feb 2013), I had used lmer to run a mixed effect model involving a binomial outcome with the following command: nl3.lmer <- glmer( cul.bi ~ food.act + where + intlan + inter.cul + via.m + via.h + (1|Id), data=drm, family=binomial) Everything had worked fine, without any error or warning messages and I had presented my results. When trying to look at it today I ran into two problems: 1) summary(nl3.lmer) Length Class Mode 1 mer S4 ...instead of the usual summary. Is it

Extracting standard deviation of random effects components using glmer

不问归期 提交于 2019-12-06 07:26:51
问题 I am using glmer and I wish to extract the standard deviation of the variance components of the random effects (intercept and slope). I have tried using: VarCorr(model) which returns the two standard deviation values (plus the correlation), but I just wish to extract the Intercept and Slope SD values. I tried using: VarrCorr(model)[1] to extract the random intercept SD, which lets me know that: attr(,"stddev") (Intercept) year 0.075 0.011 but I don't know how to extract these as individual