lme4

Post-hoc test for glmer

心不动则不痛 提交于 2019-12-22 05:23:56
问题 I'm analysing my binomial dataset with R using a generalized linear mixed model (glmer, lme4-package). I wanted to make the pairwise comparisons of a certain fixed effect ("Sound") using a Tukey's post-hoc test (glht, multcomp-package). Most of it is working fine, but one of my fixed effect variables ("SoundC") has no variance at all (96 times a "1" and zero times a "0") and it seems that the Tukey's test cannot handle that. All pairwise comparisons with this "SoundC" give a p-value of 1.000

How can I sort random effects by value of the random effect (not the intercept) in dotplot or ggplot2

烂漫一生 提交于 2019-12-21 19:57:10
问题 I suspect the answer to this question is rather simple and I just don't know what it is. Long story short, I want to display a dotplot of the random intercepts and slopes from a model I am estimating. I'm using the ggCaterpillar function helpfully introduced here. However, this function, as well as the standard dotplot from lattice, sort the ensuing graph by decreasing order of the random intercept. I would like to sort the graph by increasing value of the random effect (either alphabetical

R stargazer, lme4 and lmerTest incompatibility

杀马特。学长 韩版系。学妹 提交于 2019-12-21 13:11:41
问题 R novice here. I'm having issues working with lmerTest and stargazer . I was following the tutorial here to get stargazer to work with lme4 in R. http://svmiller.com/blog/2015/02/quasi-automating-the-inclusion-of-random-effects-in-rs-stargazer-package/ I ran this example with no issues. library(lme4) library(stargazer) data(cake) summary(M1 <- lmer(angle ~ temp + (1 | replicate) + (1|recipe:replicate), cake, REML= FALSE)) summary(M2 <- lmer(angle ~ factor(temperature) + (1 | replicate) + (1

glmer - predict with binomial data (cbind count data)

南笙酒味 提交于 2019-12-21 04:38:11
问题 I am trying to predict values over time (Days in x axis) for a glmer model that was run on my binomial data. Total Alive and Total Dead are count data. This is my model, and the corresponding steps below. full.model.dredge<-glmer(cbind(Total.Alive,Total.Dead)~(CO2.Treatment+Lime.Treatment+Day)^3+(Day|Container)+(1|index), data=Survival.data,family="binomial") We have accounted for overdispersion as you can see in the code (1:index). We then use the dredge command to determine the best fitted

k-fold cross validation for GLMM S4 class model object

狂风中的少年 提交于 2019-12-21 02:59:06
问题 I have a GLMM object fit using the glmer function in R and want to perform k-fold cross validation. For simple GLMs I have used the CVbinary function from the DAAG pkg as seen below. > SimpleGLM <- glm(Res ~ Var1 + Var2, data = Data, family=binomial) > CVbinary(SimpleGLM, nfolds=10, print.details=TRUE) Fold: 3 2 4 1 7 10 6 9 5 8 Internal estimate of accuracy = 0.828 Cross-validation estimate of accuracy = 0.827 However, when a random term for IndID is added to the model an error (below)

How do I extract the Correlation of fixed effects part of the lmer output

核能气质少年 提交于 2019-12-18 16:58:18
问题 When you have a multilevel model with lots of factors and interactions the size of the correlation of fixed effects matrix can become quite big and unclear. I can use the symbolic.cor=T parameter in the print method to make a clearer print of the summary like below: ratbrain <- within(read.delim("http://www-personal.umich.edu/~bwest/rat_brain.dat"), { treatment <- factor(treatment, labels = c("Basal", "Carbachol")) region <- factor(region, labels = c("BST", "LS", "VDB")) }) print(mod<-lmer

unscale and uncenter glmer parameters

与世无争的帅哥 提交于 2019-12-17 19:45:55
问题 I've been struggling with converting scaled and centered model coefficients from a glmer model back to uncentered and unscaled values. I analysed a dataset using GLMM in the lme4 (v1.1.7) package. It involves the calculation of maximum detection range of acoustic receivers and effect of environmental variables. Sample data: dd <- structure(list(SUR.ID = c(10186L, 10186L, 10186L, 10186L, 10186L, 10186L, 10186L, 10186L, 10186L, 10186L, 10186L, 10186L, 10186L, 10186L, 10186L, 10186L, 10186L,

using profile and boot method within confint option, with glmer model

一曲冷凌霜 提交于 2019-12-14 04:21:05
问题 I am using glmer with a logit link for a gaussian error model. When I try obtaining the confidence intervals, using either profile or the boot method with the confint option, I obtain an error for use of profile likelihood, and with bootstrapping: > Profile: Computing profile confidence intervals ... Error in > names(opt) <- profnames(fm, signames) : 'names' attribute [2] must > be the same length as the vector [1] > > Boot: Error in if (const(t, min(1e-08, mean(t, na.rm = TRUE)/1e+06))) > {

get significance of simple effects with emtrends

折月煮酒 提交于 2019-12-14 02:44:57
问题 I can get the significance of pairwise comparisons with the following code m <- lmer(angle ~ recipe*temp + (1|replicate), data=cake) emtrends(m, pairwise~recipe, var="temp") $emtrends recipe temp.trend SE df lower.CL upper.CL A 0.1537143 0.02981898 250 0.09498586 0.2124427 B 0.1645714 0.02981898 250 0.10584300 0.2232999 C 0.1558095 0.02981898 250 0.09708110 0.2145379 $contrasts contrast estimate SE df t.ratio p.value A - B -0.010857143 0.0421704 250 -0.257 0.9641 A - C -0.002095238 0.0421704

Cannot run lmer from within a function

帅比萌擦擦* 提交于 2019-12-13 20:39:32
问题 I am running into a problem trying to embed lmer within a function. Here is a reproducible example using data from lexdec . If I run lmer on the data frame directly, there is no problem. For example, say that I want to see whether reading times in a lexical decision task differed as a function of Trial . There were 2 types of word stimuli, "animal" (e.g. "dog") and "plant" (e.g. "cherry"). I can compute a mixed-effects model for animal words: library(languageR) #load lexdec data library(lme4)