mixed-models

How to plot predicted values with standard errors for lmer model results?

纵饮孤独 提交于 2019-12-10 16:09:56
问题 I have a transplant experiment for four locations and four substrates (taken from each location). I have determined survival for each population in each location and substrate combination. This experiment was replicated three times. I have created a lmm as follows: Survival.model <- lmer(Survival ~ Location + Substrate + Location:Substrate + (1|Replicate), data=Transplant.Survival,, REML = TRUE) I would like to use the predict command to extract predictions, for example: Survival.pred <-

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

筅森魡賤 提交于 2019-12-09 06:42:55
问题 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

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

Planned Contrasts on glmmTMB

孤街醉人 提交于 2019-12-08 07:58:00
问题 Apologies if this is a repeat question. Many have posted looking looking for a way to do post-hoc analyses on the conditional model (fixed factors) in glmmTMB. I want to do plannned contrasts between certain groups, not test every pairwise comparison (e.g. Tukey). The code below worked well on nlme:lme for a lmm. However, it returns an error on the code below. Error in modelparm.default(model, ...) : dimensions of coefficients and covariance matrix don't match Is there a way to do planned

Interpreting mcmc output using glmmadmb

无人久伴 提交于 2019-12-08 03:57:46
问题 I'm trying to evaluate the output from a negative binomial mixed model using glmmadmb. To summarize the output I'm comparing the summary function with output forom the mcmc option. I have run this model: pre1 <- glmmadmb(walleye~(1|year.center) + (1|Site) ,data=pre, family="nbinom2",link="log", mcmc=TRUE,mcmc.opts=mcmcControl(mcmc=1000)) I have two random intercepts: year and site. Year has 33 levels and site has 15. The random effect parameter estimate for site and year from summary(pre1) do

Planned Contrasts on glmmTMB

大憨熊 提交于 2019-12-06 14:54:02
Apologies if this is a repeat question. Many have posted looking looking for a way to do post-hoc analyses on the conditional model (fixed factors) in glmmTMB. I want to do plannned contrasts between certain groups, not test every pairwise comparison (e.g. Tukey). The code below worked well on nlme:lme for a lmm. However, it returns an error on the code below. Error in modelparm.default(model, ...) : dimensions of coefficients and covariance matrix don't match Is there a way to do planned contrasts on a glmmTMB? #filtdens is a dataframe and TRT,DATE,BURN,VEG are factors filtdens <- merged %>%

How do regression models deal with the factor variables?

丶灬走出姿态 提交于 2019-12-06 08:52:08
Suppose I have a data with a factor and response variable. My questions: How linear regression and mixed effect models work with the factor variables? If I have a separate model for each level of the factor variable (m3 and m4) , how does that differ with models m1 and m2 ? Which one is the best model/approach? As an example I use Orthodont data in nlme package. library(nlme) data = Orthodont data2 <- subset(data, Sex=="Male") data3 <- subset(data, Sex=="Female") m1 <- lm (distance ~ age + Sex, data = Orthodont) m2 <- lme(distance ~ age , data = Orthodont, random = ~ 1|Sex) m3 <- lm(distance ~

fitting a linear mixed model to a very large data set

喜夏-厌秋 提交于 2019-12-06 03:01:14
问题 I want to run a mixed model (using lme4::lmer ) on 60M observations of the following format; all predictor/dependent variables are categorical (factors) apart from the continuous dependent variable tc ; patient is the grouping variable for a random intercept term. I have 64-bit R and 16Gb RAM and I'm working from a central server. RStudio is the most recent server version. model <- lmer(tc~sex+age+lho+atc+(1|patient), data=master,REML=TRUE) lho sex tc age atc patient 18 M 16.61 45-54 H 628143

How to specify different random effects in nlme vs. lme4?

自闭症网瘾萝莉.ら 提交于 2019-12-06 02:04:18
问题 I want to specify different random effects in a model using nlme::lme (data at the bottom). The random effects are: 1) intercept and position varies over subject ; 2) intercept varies over comparison . This is straightforward using lme4::lmer : lmer(rating ~ 1 + position + (1 + position | subject) + (1 | comparison), data=d) > ... Random effects: Groups Name Std.Dev. Corr comparison (Intercept) 0.31877 subject (Intercept) 0.63289 position 0.06254 -1.00 Residual 0.91458 ... However, I want to

lmer error: grouping factor must be < number of observations

扶醉桌前 提交于 2019-12-05 18:20:23
I am attempting to run a mixed effect model on some data but struggling with one of the fixed effects, I think primarily due to it a factor?! Sample data: data4<-structure(list(code = structure(1:10, .Label = c("10888", "10889", "10890", "10891", "10892", "10893", "10894", "10896", "10897", "10898", "10899", "10900", "10901", "10902", "10903", "10904", "10905", "10906", "10907", "10908", "10909", "10910", "10914", "10916", "10917", "10919", "10920", "10922", "10923", "10924", "10925", "10927"), class = "factor"), speed = c(0.0296315046039244, 0.0366986630049636, 0.0294297725505692, 0