[R] Help Interpreting Linear Mixed Model
John Kane
jrkrideau at inbox.com
Tue Apr 28 03:39:57 CEST 2015
Looks great. How come so many NA's in Height and BMI? Just no data available?
str(dat1)
'data.frame': 100 obs. of 8 variables:
$ Id : int 7451 148 10393 10200 1961 10428 10541 10012 9895 10626 ...
$ Level : Factor w/ 5 levels "CHAMPIONSHIP",..: 1 1 1 1 1 1 1 1 1 1 ...
$ AgeGr : int 14 16 10 10 13 10 10 10 10 10 ...
$ Position: Factor w/ 4 levels "D","F","GK","M": 4 1 1 2 3 3 2 3 1 1 ...
$ Height : int NA NA NA NA NA NA NA NA NA NA ...
$ Weight : num 63 64 36 46 67 40 25 30 36 33 ...
$ BMI : num NA NA NA NA NA NA NA NA NA NA ...
$ YoYo : int 80 80 160 160 160 160 160 160 160 160 ...
John Kane
Kingston ON Canada
-----Original Message-----
From: joshuamichaeldixon at gmail.com
Sent: Mon, 27 Apr 2015 23:35:13 +0100
To: jrkrideau at inbox.com
Subject: Re: [R] Help Interpreting Linear Mixed Model
Thanks John!
This ok?
> dput(head(data, 100))
structure(list(Id = c(7451L, 148L, 10393L, 10200L, 1961L, 10428L,
10541L, 10012L, 9895L, 10626L, 1151L, 8775L, 10083L, 6217L, 90L,
10168L, 10291L, 8549L, 3451L, 10003L, 5907L, 10136L, 6182L, 6315L,
10015L, 9956L, 2040L, 4710L, 10747L, 6787L, 1222L, 10757L, 2892L,
117L, 10328L, 10503L, 768L, 2979L, 1961L, 10520L, 10498L, 3018L,
10335L, 2448L, 9027L, 362L, 8499L, 10603L, 9489L, 2124L, 707L,
8501L, 4908L, 9905L, 3000L, 2819L, 9973L, 10550L, 9921L, 10639L,
8771L, 10121L, 32L, 9935L, 9299L, 3246L, 682L, 10325L, 6741L,
3295L, 5270L, 727L, 8500L, 50L, 4705L, 3018L, 787L, 2953L, 1391L,
3682L, 7974L, 5023L, 652L, 727L, 679L, 10212L, 9488L, 9987L,
10039L, 5025L, 250L, 2539L, 787L, 3000L, 1151L, 8946L, 6177L,
3296L, 250L, 498L), Level = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("CHAMPIONSHIP",
"CONFERENCE", "LEAGUE_ONE", "LEAGUE_TWO", "PREMIER_LEAGUE"), class = "factor"),
AgeGr = c(14L, 16L, 10L, 10L, 13L, 10L, 10L, 10L, 10L, 10L,
14L, 10L, 10L, 10L, 12L, 10L, 10L, 12L, 10L, 10L, 10L, 10L,
12L, 10L, 10L, 10L, 10L, 10L, 10L, 15L, 10L, 10L, 10L, 12L,
10L, 10L, 13L, 10L, 13L, 11L, 11L, 13L, 12L, 11L, 12L, 14L,
13L, 13L, 13L, 13L, 12L, 11L, 15L, 11L, 14L, 13L, 11L, 11L,
11L, 12L, 14L, 12L, 13L, 11L, 13L, 15L, 11L, 13L, 13L, 13L,
14L, 13L, 13L, 12L, 13L, 13L, 13L, 14L, 12L, 14L, 13L, 13L,
13L, 13L, 13L, 12L, 13L, 14L, 13L, 14L, 13L, 14L, 13L, 14L,
14L, 13L, 14L, 13L, 13L, 13L), Position = structure(c(4L,
1L, 1L, 2L, 3L, 3L, 2L, 3L, 1L, 1L, 1L, 2L, 4L, 3L, 2L, 3L,
4L, 3L, 4L, 2L, 4L, 2L, 3L, 1L, 1L, 2L, 4L, 4L, 2L, 4L, 4L,
2L, 1L, 4L, 1L, 1L, 2L, 4L, 3L, 1L, 4L, 1L, 2L, 3L, 3L, 1L,
1L, 3L, 1L, 3L, 4L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 3L, 1L,
2L, 2L, 2L, 4L, 4L, 2L, 4L, 2L, 3L, 3L, 4L, 4L, 1L, 1L, 1L,
2L, 2L, 4L, 1L, 1L, 1L, 2L, 4L, 1L, 3L, 4L, 4L, 4L, 4L, 2L,
2L, 2L, 1L, 1L, 4L, 1L, 4L, 2L, 2L), .Label = c("D", "F",
"GK", "M"), class = "factor"), Height = c(NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 151L, NA,
154L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 156L, NA,
147L, NA, NA, NA, NA, NA, 138L, 172L, NA, NA, 150L, NA, NA,
NA, NA, NA, NA, NA, 140L, 153L, NA, NA, NA, NA, NA, NA, NA,
158L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 156L), Weight = c(63,
64, 36, 46, 67, 40, 25, 30, 36, 33, 61, 31, 29, 34, 47, 38,
32, 44, 32, 32, 30, 34, 51, 34, 28, 27, 33, 31, 28, 44, 37,
46, 26, 42, 32, 32, 43, 31, 72, 27, 30, 55, 53, 50, 51, 55,
48.6, 49, 48, 64, 35, 32, 55, 32, 50, 61, 42, 33, 37, 45,
45, 50, 36, 33, 49, 59, 42, 43, 35.1, 66.9, 52, 47, 40, 38,
45, 53, 44, 54, 39, 62, 33, 53.8, 42, 46, 39, 48, 39, 54,
40, 42.4, 50, 48, 46, 52, 58, 40, 46, 51, 54, 42), BMI = c(NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
21.2, NA, 20.24, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, 18.49, NA, 16.66, NA, NA, NA, NA, NA, 18.57, 22.61, NA,
NA, 17.77, NA, NA, NA, NA, NA, NA, NA, 16.84, 22.86, NA,
NA, NA, NA, NA, NA, NA, 16.9, NA, NA, NA, NA, NA, NA, NA,
NA, NA, 17.26), YoYo = c(80L, 80L, 160L, 160L, 160L, 160L,
160L, 160L, 160L, 160L, 160L, 160L, 160L, 160L, 160L, 160L,
160L, 160L, 160L, 160L, 160L, 160L, 160L, 160L, 160L, 160L,
160L, 160L, 160L, 160L, 160L, 160L, 160L, 160L, 160L, 160L,
160L, 160L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L,
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L,
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L,
200L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L)), .Names = c("Id", "Level", "AgeGr",
"Position", "Height", "Weight", "BMI", "YoYo"), row.names = c(NA,
100L), class = "data.frame")
On Mon, Apr 27, 2015 at 10:43 PM, John Kane <jrkrideau at inbox.com> wrote:
Hi Josh,
Just a sample is usually fine. As long as it cover a representative (must be time for dinner---I was going to type reprehensibe) sample of the data then something like dput(head(mydata, 100) ) works well.
Kingston ON Canada
-----Original Message-----
From: joshuamichaeldixon at gmail.com
Sent: Mon, 27 Apr 2015 21:30:39 +0100
To: lists at dewey.myzen.co.uk
Subject: Re: [R] Help Interpreting Linear Mixed Model
Apologies for my ignorance!
Thierry - thank you for the reading. I'll look into those ASAP!
John - The data set I have is quite large, when using the dput() command I'm unsure if it actually fits the whole output into the console. I can't scroll up far enough to see the actual command. I can paste what is there if that may help? The bottom line:
Names = c("Id", "Level", "AgeGr", "Position", "Height", "Weight", "BMI", "YoYo"), class = "data.frame", row.names = c(NA, -9689L))
Michael - Essentially, I'm looking for differences between "YoYo" outcome for "Positions", "Levels" and accounting for repeated measures using "Id" as a random factor. So I was able to figure out points 2 and 3.
I've searched for definitions of "Scaled residuals", "Random effects", "Fixed effects", "Correlation of Fixed Effects". However, I'm confused at the different interpretations I've found. Or quite possibly, I'm just confused... What should I be looking out for in these variables?
I've tried to take my analysis smaller, and just look at specifics, to make it simpler. Such as, comparing YoYo (outcome score) for a Premier_League (Level), 22 (AgeGr) F (Position) with a Premier_League (Level), 22 (AgeGr) M (Position). How do I convert these into a factors for analysis?
Simple question maybe, but it's not when you can't find the answer!
Thank you,
Josh
On Mon, Apr 27, 2015 at 4:10 PM, Michael Dewey <lists at dewey.myzen.co.uk> wrote:
Dear Joshua
It would also help if you told us what your scientific question was. At the moment we know what R commands you used and have seen the head of your dataset but not why you are doing it.
I would summarise what you have given us as
1 - most ID only occur once
2 - goal keepers do worse than outfield players
3 - older people (presumably in fact age is in years as a continuous variable) do better
On 27/04/2015 12:42, John Kane wrote:
John Kane
Kingston ON Canada
-----Original Message-----
From: joshuamichaeldixon at gmail.com
Sent: Mon, 27 Apr 2015 08:54:51 +0100
To: thierry.onkelinx at inbo.be
Subject: Re: [R] Help Interpreting Linear Mixed Model
Hello Thierry,
No, this isn't homework. Not that young unfortunately.
A few years ago a friend of mine and her daughter were neck-in-neck on who got their Ph.D first. What's this "not that young" business?
BTW, a better way to supply sample data is to use the dput() command.
Do a dput(mydata), copy the results into the email and you have supplied us with an exact copy of your data.
It is possible for many reasons that I will not read in your data, as you supplied it, in the format you have it in. This can lead to real confusion.
Josh
On 27 Apr 2015, at 08:06, Thierry Onkelinx <thierry.onkelinx at inbo.be>
wrote:
Dear Josh,
Is this homework? Because the list has a no homework policy.
Best regards,
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
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
2015-04-27 2:26 GMT+02:00 Joshua Dixon <joshuamichaeldixon at gmail.com>:
Hello!
Very new to R (10 days), and I've run the linear mixed model, below.
Attempting to interpret what it means... What do I need to look for?
Residuals, correlations of fixed effects?!
How would I look at very specific interactions, such as PREMIER_LEAGUE
(Level) 18 (AgeGr) GK (Position) mean difference to CHAMPIONSHIP 18
GK?
For reference my data set looks like this:
Id Level AgeGr Position Height Weight BMI YoYo
7451 CHAMPIONSHIP 14 M NA 63 NA 80
148 PREMIER_LEAGUE 16 D NA 64 NA 80
10393 CONFERENCE 10 D NA 36 NA 160
10200 CHAMPIONSHIP 10 F NA 46 NA 160
1961 LEAGUE_TWO 13 GK NA 67 NA 160
10428 CHAMPIONSHIP 10 GK NA 40 NA 160
10541 LEAGUE_ONE 10 F NA 25 NA 160
10012 CHAMPIONSHIP 10 GK NA 30 NA 160
9895 CHAMPIONSHIP 10 D NA 36 NA 160
Many thanks in advance for time and help. Really appreciate it.
Josh
summary(lmer(YoYo~AgeGr+Position+(1|Id)))
Linear mixed model fit by REML ['lmerMod']
Formula: YoYo ~ AgeGr + Position + (1 | Id)
REML criterion at convergence: 125712.2
Scaled residuals:
Min 1Q Median 3Q Max
-3.4407 -0.5288 -0.0874 0.4531 4.8242
Random effects:
Groups Name Variance Std.Dev.
Id (Intercept) 15300 123.7
Residual 16530 128.6
Number of obs: 9609, groups: Id, 6071
Fixed effects:
Estimate Std. Error t value
(Intercept) -521.6985 16.8392 -30.98
AgeGr 62.6786 0.9783 64.07
PositionD 139.4682 7.8568 17.75
PositionM 141.2227 7.7072 18.32
PositionF 135.1241 8.1911 16.50
Correlation of Fixed Effects:
(Intr) AgeGr PostnD PostnM
AgeGr -0.910
PositionD -0.359 -0.009
PositionM -0.375 0.001 0.810
PositionF -0.349 -0.003 0.756 0.782
model=lmer(YoYo~AgeGr+Position+(1|Id))
summary(glht(model,linfct=mcp(Position="Tukey")))
Simultaneous Tests for General Linear Hypotheses
Multiple Comparisons of Means: Tukey Contrasts
Fit: lmer(formula = YoYo ~ AgeGr + Position + (1 | Id))
Linear Hypotheses:
Estimate Std. Error z value Pr(>|z|)
D - GK == 0 139.468 7.857 17.751 <1e-04 ***
M - GK == 0 141.223 7.707 18.323 <1e-04 ***
F - GK == 0 135.124 8.191 16.496 <1e-04 ***
M - D == 0 1.754 4.799 0.366 0.983
F - D == 0 -4.344 5.616 -0.774 0.862
F - M == 0 -6.099 5.267 -1.158 0.645
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Adjusted p values reported -- single-step method)
[[alternative HTML version deleted]]
______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help [https://stat.ethz.ch/mailman/listinfo/r-help] [https://stat.ethz.ch/mailman/listinfo/r-help [https://stat.ethz.ch/mailman/listinfo/r-help]]
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html [http://www.R-project.org/posting-guide.html] [http://www.R-project.org/posting-guide.html [http://www.R-project.org/posting-guide.html]]
and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help [https://stat.ethz.ch/mailman/listinfo/r-help] [https://stat.ethz.ch/mailman/listinfo/r-help [https://stat.ethz.ch/mailman/listinfo/r-help]]
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html [http://www.R-project.org/posting-guide.html] [http://www.R-project.org/posting-guide.html [http://www.R-project.org/posting-guide.html]]
and provide commented, minimal, self-contained, reproducible code.
____________________________________________________________
FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family!
Visit http://www.inbox.com/photosharing [http://www.inbox.com/photosharing] [http://www.inbox.com/photosharing [http://www.inbox.com/photosharing]] to find out more!
______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help [https://stat.ethz.ch/mailman/listinfo/r-help] [https://stat.ethz.ch/mailman/listinfo/r-help [https://stat.ethz.ch/mailman/listinfo/r-help]]
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html [http://www.R-project.org/posting-guide.html] [http://www.R-project.org/posting-guide.html [http://www.R-project.org/posting-guide.html]]
and provide commented, minimal, self-contained, reproducible code.
--
Michael
http://www.dewey.myzen.co.uk/home.html [http://www.dewey.myzen.co.uk/home.html] [http://www.dewey.myzen.co.uk/home.html [http://www.dewey.myzen.co.uk/home.html]]
____________________________________________________________
Can't remember your password? Do you need a strong and secure password?
Use Password manager! It stores your passwords & protects your account.
Check it out at http://mysecurelogon.com/manager [http://mysecurelogon.com/manager]
____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
More information about the R-help
mailing list