mixed-models

multinomial mixed logit model mlogit r-package

那年仲夏 提交于 2019-12-03 15:31:03
I discovered the mlogit - package for multinomial logit models in search of estimating a multinomial mixed logit model. After reading the excellent vignette I discovered that I could not apply my data on any of the described examples. I now write in hope of help with my problem and created a minimal example to illustrate my situation. The Problem is as follows: There are words with the consonant 'Q' somewhere. Now an experiment was conducted with people who were tasked to listen to these words and say if they heard a Q, an U or some OTHER consonant. This has to modeled in dependence of some

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

How to plot random intercept and slope in a mixed model with multiple predictors?

[亡魂溺海] 提交于 2019-12-03 07:38:50
Is it possible to plot the random intercept or slope of a mixed model when it has more than one predictor? With one predictor I would do like this: #generate one response, two predictors and one factor (random effect) resp<-runif(100,1, 100) pred1<-c(resp[1:50]+rnorm(50, -10, 10),resp[1:50]+rnorm(50, 20, 5)) pred2<-resp+rnorm(100, -10, 10) RF1<-gl(2, 50) #gamm library(mgcv) mod<-gamm(resp ~ pred1, random=list(RF1=~1)) plot(pred1, resp, type="n") for (i in ranef(mod$lme)[[1]]) { abline(fixef(mod$lme)[1]+i, fixef(mod$lme)[2]) } #lmer library(lme4) mod<-lmer(resp ~ pred1 + (1|RF1)) plot(pred1,

test for significance of interaction in linear mixed models in nlme in R

烈酒焚心 提交于 2019-12-03 03:36:23
I use lme function in the nlme R package to test if levels of factor items has significant interaction with levels of factor condition . The factor condition has two levels: Control and Treatment , and the factor items has 3 levels: E1,...,E3 . I use the following code: f.lme = lme(response ~ 0 + factor(condition) * factor(items), random = ~1|subject) where subject is the random effect. In this way, when I run: summary(f.lme)$tTable I will get the following output: factor(condition)Control factor(condition)Treatment factor(items)E2 factor(items)E3 factor(condition)Treatment:factor(items)E2

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 ~

Python Statsmodels Mixedlm (Mixed Linear Model) random effects

眉间皱痕 提交于 2019-12-01 06:46:04
I am a bit confused about the output of Statsmodels Mixedlm and am hoping someone could explain. I have a large dataset of single family homes, including the previous two sale prices/sale dates for each property. I have geocoded this entire dataset and fetched the elevation for each property. I am trying to understand the way in which the relationship between elevation and property price appreciation varies between different cities. I have used statsmodels mixed linear model to regress price appreciation on elevation, holding a number of other factors constant, with cities as my groups

Python Statsmodels Mixedlm (Mixed Linear Model) random effects

孤街浪徒 提交于 2019-12-01 04:58:21
问题 I am a bit confused about the output of Statsmodels Mixedlm and am hoping someone could explain. I have a large dataset of single family homes, including the previous two sale prices/sale dates for each property. I have geocoded this entire dataset and fetched the elevation for each property. I am trying to understand the way in which the relationship between elevation and property price appreciation varies between different cities. I have used statsmodels mixed linear model to regress price

R: Interaction Plot with a continuous and a categorical variable for a GLMM (lme4)

依然范特西╮ 提交于 2019-11-30 13:31:57
问题 I would like to make an interaction plot to visually display the difference or similarity in slopes of interaction of a categorical variable (4 levels) and a standardized continuous variable from the results of a regression model. with(GLMModel, interaction.plot(continuous.var, categorical.var, response.var)) Is not what I am looking for. It produces a plot in which the slope changes for each value of the continuous variable. I'm looking to make a plot with constant slopes as in the following

R: Interaction Plot with a continuous and a categorical variable for a GLMM (lme4)

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 07:32:08
I would like to make an interaction plot to visually display the difference or similarity in slopes of interaction of a categorical variable (4 levels) and a standardized continuous variable from the results of a regression model. with(GLMModel, interaction.plot(continuous.var, categorical.var, response.var)) Is not what I am looking for. It produces a plot in which the slope changes for each value of the continuous variable. I'm looking to make a plot with constant slopes as in the following plot: Any ideas? I fit a model of the form fit<-glmer(resp.var ~ cont.var*cat.var + (1|rand.eff) ,

Converting Repeated Measures mixed model formula from SAS to R

≡放荡痞女 提交于 2019-11-29 23:22:37
There are several questions and posts about mixed models for more complex experimental designs, so I thought this more simple model would help other beginners in this process as well as I. So, my question is I would like to formulate a repeated measures ancova in R from sas proc mixed procedure: proc mixed data=df1; FitStatistics=akaike class GROUP person day; model Y = GROUP X1 / solution alpha=.1 cl; repeated / type=cs subject=person group=GROUP; lsmeans GROUP; run; Here is the SAS output using the data created in R (below): . Effect panel Estimate Error DF t Value Pr > |t| Alpha Lower Upper