lme4

Obtaining random-effects matrices from a mixed model

↘锁芯ラ 提交于 2021-02-18 08:43:31
问题 In my below code, I was wondering how I can obtain the equivalent of out and Ts from an lme() object in the library(nlme) ? dat <- read.csv("https://raw.githubusercontent.com/rnorouzian/v/main/mv.l.csv") library(lme4) x <- lmer(value ~0 + name+ (1| School/Student), data = dat, control = lmerControl(check.nobs.vs.nRE= "ignore")) lwr <- getME(x, "lower") theta <- getME(x, "theta") out = any(theta[lwr == 0] < 1e-4) # find this from `x1` object below Ts = getME(x, "Tlist") # find this from `x1`

Obtaining random-effects matrices from a mixed model

被刻印的时光 ゝ 提交于 2021-02-18 08:42:23
问题 In my below code, I was wondering how I can obtain the equivalent of out and Ts from an lme() object in the library(nlme) ? dat <- read.csv("https://raw.githubusercontent.com/rnorouzian/v/main/mv.l.csv") library(lme4) x <- lmer(value ~0 + name+ (1| School/Student), data = dat, control = lmerControl(check.nobs.vs.nRE= "ignore")) lwr <- getME(x, "lower") theta <- getME(x, "theta") out = any(theta[lwr == 0] < 1e-4) # find this from `x1` object below Ts = getME(x, "Tlist") # find this from `x1`

Error when estimating CI for GLMM using confint()

寵の児 提交于 2021-02-10 13:27:31
问题 I have a set of GLMMs fitted with a binary response variable and a set of continuous variables, and I would like to get confidence intervals for each model. I've been using confint() function, at 95% and with the profile method, and it works without any problems if it is applied to a model with no interactions. However, when I apply confint() to a model with interactions (continuous*continuous), I've been getting this error: m1CI <- confint(m1, level=0.95, method="profile") Error in zeta

Extract posterior estimate and credible intervals for random effect for lme4 model in R

时光总嘲笑我的痴心妄想 提交于 2021-02-10 12:41:07
问题 I need to extract the posterior estimates and intervals for a random effect from my model. For illustrative purposes, a similar dataset to the one I am using would be the ChickWeight dataset in base R. The way I extract the posterior estimates and intervals for my fixed effects is like so: #load package library(lme4) #model m.surv<-lmer(weight ~ Time + Diet + (1|Chick), data=ChickWeight) #load packages library(MCMCglmm) library(arm) #set up for fixed effects sm.surv<-sim(m.surv) smfixef.surv

Extract posterior estimate and credible intervals for random effect for lme4 model in R

瘦欲@ 提交于 2021-02-10 12:40:00
问题 I need to extract the posterior estimates and intervals for a random effect from my model. For illustrative purposes, a similar dataset to the one I am using would be the ChickWeight dataset in base R. The way I extract the posterior estimates and intervals for my fixed effects is like so: #load package library(lme4) #model m.surv<-lmer(weight ~ Time + Diet + (1|Chick), data=ChickWeight) #load packages library(MCMCglmm) library(arm) #set up for fixed effects sm.surv<-sim(m.surv) smfixef.surv

predict with glmer where new data is a Raster Stack of fixed efefcts

旧城冷巷雨未停 提交于 2021-02-08 11:59:30
问题 I have constructed models in glmer and would like to predict these on a rasterStack representing the fixed effects in my model. my glmer model is in the form of: m1<-glmer(Severity ~ x1 + x2 + x3 + (1 | Year) + (1 | Ecoregion), family=binomial( logit )) As you can see, I have random effects which I don't have as spatial layer - for example 'year'. Therefore the problem is really predicting glmer on rasterStacks when you don't have the random effects data random effects layers. If I use it out

(MuMIn) Dredge when global mixed-effects model is rank deficient

帅比萌擦擦* 提交于 2021-02-08 10:17:00
问题 I am trying to run variable selection on Poisson mixed-effect models using glmer() and dredge() . Since several variables are collinear I use the subsetting function of dredge to avoid correlated variables. However, to use dredge() effectively one needs to have a full model including all terms - which can lead to full model to be rank-deficient. [edited Feb 15 2016] To give a reproducible example, let's generate a random data set: dfdat<-data.frame(replicate(6, round(rnorm(6),2))) dfdat$group

combine two plots into one plot in a mixed-model plot

点点圈 提交于 2021-02-08 06:41:06
问题 In my plot below, d_math and d_hyp are each {0,1} variables. Given this fact, in my plot below, I was wondering if we can combine the two plots into one, just like in the desired plot further below? ps. I'm open to any R packages. multivariate <- read.csv('https://raw.githubusercontent.com/hkil/m/master/bv.csv') library(nlme) library(effects) # for plot m2 <- lme(var ~ 0 + d_math + d_hyp + d_math:I(grade-2) + d_hyp:I(grade-2), random = ~ 0 + d_math + d_hyp + d_math:I(grade-2) + d_hyp:I(grade

combine two plots into one plot in a mixed-model plot

早过忘川 提交于 2021-02-08 06:40:55
问题 In my plot below, d_math and d_hyp are each {0,1} variables. Given this fact, in my plot below, I was wondering if we can combine the two plots into one, just like in the desired plot further below? ps. I'm open to any R packages. multivariate <- read.csv('https://raw.githubusercontent.com/hkil/m/master/bv.csv') library(nlme) library(effects) # for plot m2 <- lme(var ~ 0 + d_math + d_hyp + d_math:I(grade-2) + d_hyp:I(grade-2), random = ~ 0 + d_math + d_hyp + d_math:I(grade-2) + d_hyp:I(grade

Extracting names from a VarCorr object in lme4 and pasting it as column names

╄→尐↘猪︶ㄣ 提交于 2021-02-08 06:33:09
问题 Below I was wondering if there might be a way to extract the columns Name and Groups from vc1 and vc2 and respectively paste them as the column names for objects AA , BB . For example, for MODEL 1 (below), my expected output of AA will be: plate_(Intercept) #: Name & Groups column from `vc1` Standard deviation 1.54 Proportion of Variance 1.00 Cumulative Proportion 1.00 sample_(Intercept) #: Name & Groups column from `vc1` Standard deviation 3.513 Proportion of Variance 1.000 Cumulative