# [R-sig-ME] mixed-ish model

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Thu Jan 22 10:03:49 CET 2015

```Dear David,

Unfortunately 3 levels of s is not enough to fit a sensible mixed model. This is discussed at http://glmm.wikidot.com/faq

Best regards,

Thierry

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
Thierry.Onkelinx op inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

-----Oorspronkelijk bericht-----
Van: R-sig-mixed-models [mailto:r-sig-mixed-models-bounces op r-project.org] Namens David Stevens
Verzonden: woensdag 21 januari 2015 22:35
Aan: r-sig-mixed-models op r-project.org
Onderwerp: [R-sig-ME] mixed-ish model

I have a mixed-effects model problem in which y ~ x|s where s is a random effect and x is a fixed effect. s has three levels (0,1,2) and I'm looking for a lmer(...) solution to the case where if s == c(1,2), the slope is the same but the intercept is different. If s == 0, slope and intercept are different.

lmer(y~x + (1+x|s)) yields three slopes and three intercepts

If I define s2 = 0 for s = 0 and s2 = 1 for s %in% (1,2) lmer(y~x + (1+x|s2)) yields two slopes and two intercepts

I can brute force this using categorical variables and lm(...) , but I was hoping for a more R-ish way. Any thoughts or pointers?

Here are the data
# ... x
x <- c(190,110,150,170,170,170,200,140,140,160,140,110,110,120,110,110,110)
x <-  c(x,140,140,120,190,120,110,110,100,100,120,120,100,80,100)
x <- c(x,580,640,500,530,670,670,640,0640,560,590,640,590,600)
# ... y
y <-
c(5.96,6.08,5.93,5.99,6.01,5.97,5.88,6.06,6.06,6.03,6.02,6.17,6.31,6.27,6.42,6.28,6.43)
y <-
c(y,6.33,6.43,6.37,6.09,6.32,6.37,6.73,6.89,6.87,6.3,6.52,6.39,6.87,6.85)
y <- c(y,5.82,5.94,5.73,5.91,5.87,5.8,5.8,5.78,5.78,5.73,5.63,5.79,6.02)
# ... s
s <- as.factor(c(rep(1,17),rep(2,14),rep(0,13)))
y.df = data.frame(x=x,y=y,s=s)
y.df\$s2 <- as.factor(1 - as.numeric( !(y.df\$s %in% c(1,2))))

Thanks

David

--
David K Stevens, P.E., Ph.D.
Professor and Head, Environmental Engineering Civil and Environmental Engineering Utah Water Research Laboratory
8200 Old Main Hill
Logan, UT  84322-8200
435 797 3229 - voice
435 797 1363 - fax
david.stevens op usu.edu

_______________________________________________
R-sig-mixed-models op r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
Disclaimer<https://www.inbo.be/nl/disclaimer-mailberichten-van-het-inbo>

```