Title: Part IV The General Linear Model. Multiple Explanatory Variables Chapter 13.3 Fixed *Random Effects Paired t-test
1Part IVThe General Linear Model. Multiple
Explanatory VariablesChapter 13.3 Fixed
Random EffectsPaired t-test
2Overview of GLM
GLM
3GLM Paired t-test
- Two factors (2 explanatory variables on a nominal
scale) - One fixed (2 categories)
- The other random (many categories)
Random factor Remove var. among units ?
sensitive test
Fixed factor
4GLM Paired t-test
- Sleep data example, used by W. Gosset (1908) in
the paper that introduced the t-test - Are the effects of 2 sleep inducing drugs
Hyoscyamine (Drug A) and L Hyoscine (Drug B),
controlled for among subject variation, different?
Subject DrugA Drug B
1 0.7 1.9
2 -1.6 0.8
3 -0.2 1.1
4 -1.2 0.1
5 -0.1 -0.1
6 3.4 4.4
7 3.7 5.5
8 0.8 1.6
9 0.0 4.6
10 2.0 3.4
51. Construct Model
- Response variable Thours of extra sleep ratio
scale - Explanatory variables
- 1. Drug. XD Drug A, Drug B. Nominal scale
- Fixed effect
- 2. Subject. XS 1,2,,10. Nominal scale
- Random effect
- Mean value for each subject varies randomly and
is not under the control of the investigator
61. Construct Model
- Verbal Hours of extra sleep depends on drug.
- Graphical
71. Construct Model
- Verbal Hours of extra sleep depends on drug.
- Graphical
81. Construct Model
- Verbal Hours of extra sleep depends on drug.
- Graphical
91. Construct Model
Can we have an interaction term? Lets look at
the df dfDrug dfSubject
dfDrugSubject Dfresidual
101. Construct Model
- Verbal Hours of extra sleep depends on drug.
- Graphical
111. Construct Model
122. Execute analysis
XS T XD
1 0.7 A
2 -1.6 A
3 -0.2 A
4 -1.2 A
5 -0.1 A
6 3.4 A
7 3.7 A
8 0.8 A
9 0.0 A
10 2.0 A
1 1.9 B
2 0.8 B
3 1.1 B
4 0.1 B
5 -0.1 B
6 4.4 B
7 5.5 B
8 1.6 B
9 4.6 B
10 3.4 B
lm1 lt- lm(TXSXD, datasleep)
R multiple ways to model random effects Instead
of lm lmerlme4 lmenlme use aov() ,
specifying Error(subject)
132. Execute analysis
- Compute
- Compute mean per drug mean (TDA)
0.75 hs - Compute drug effect
- 4. Compute mean per subject mean(TS1) 1.3
hs - 5. Compute subject effect
- 6. Compute fits
- 7. Compute residuals residuals T - fits
142. Execute analysis
XS T XD ß0 ßD ßS fits res
1 0.7 A 1.54 -0.79 -0.24 0.51 -0.19
2 -1.6 A 1.54 -0.79 -1.94 -1.19 0.41
3 -0.2 A 1.54 -0.79 -1.09 -0.34 -0.14
4 -1.2 A 1.54 -0.79 -2.09 -1.34 -0.14
5 -0.1 A 1.54 -0.79 -1.64 -0.89 -0.79
1 1.9 B 1.54 0.79 -0.24 2.09 0.19
2 0.8 B 1.54 0.79 -1.94 0.39 -0.41
3 1.1 B 1.54 0.79 -1.09 1.24 0.14
4 0.1 B 1.54 0.79 -2.09 0.24 0.14
5 -0.1 B 1.54 0.79 -1.64 0.69 0.79
153. Evaluate model
- Straight line model ok?
- Errors homogeneous?
- Errors normal?
- Errors independent?
163. Evaluate model
NA
- Straight line model ok?
- Errors homogeneous?
- Errors normal?
- Errors independent?
?
173. Evaluate model
NA
- Straight line model ok?
- Errors homogeneous?
- Errors normal?
- Errors independent?
?
?
183. Evaluate model
NA
- Straight line model ok?
- Errors homogeneous?
- Errors normal?
- Errors independent?
?
?
19- State the population and whether the sample is
representative. - Drugs set by experimental design ? fixed
effects We will infer only to those drugs - Subjects, chosen at random. Hopefully from a
larger population ? random effects -
- Population of all possible measurements of hours
of extra sleep, given the mode of collection - Infer to a population of subjects with
characteristics similar to those in the study
20- Decide on mode of inference. Is hypothesis
testing appropriate? - State HA / Ho pair, test statistic, distribution,
tolerance for Type I error. - Assume no interaction, i.e. effect of drug is
consistent across subjects - Focus on drug effect
21- State HA / Ho pair, test statistic, distribution,
tolerance for Type I error. - Test Statistic
- Distribution of test statitstic
- Tolerance for Type I error
227. ANOVA
n 20
Source df SS MS F p
Subject
Drug
Res ______ ______
Total
237. ANOVA
n 20
Source df SS MS F p
Subject 9 58.078
Drug 1 12.482
Res ___9__ _6.808
Total 19 77.37
247. ANOVA
n 20
Source df SS MS F p
Subject 9 58.078 6.453
Drug 1 12.482 12.48
Res ___9__ _6.808 0.7564
Total 19 77.37
257. ANOVA
n 20
Source df SS MS F p
Subject 9 58.078 6.453
Drug 1 12.482 12.48 16.5 0.0028
Res ___9__ _6.808 0.7564
Total 19 77.37
267. ANOVA
n 20
Source df SS MS F p
Subject 9 58.078 6.453
Drug 1 12.482 12.48 16.5 0.0028
Res ___9__ _6.808 0.7564
Total 19 77.37
r2 0.91
STATISTICAL CONTROL
BUT we did this before ? Ch 10.2 2 sample t-test
Source df SS MS F p
Drug 1 12.48 12.48 3.4626 0.079
Res __18__ 64.886 3.6048
Total 19 77.37
r2 0.16
278. Decide whether to recompute p-valueSlight
deviation from normalitynlt30, p0.0028 not near
a ? no need to recompute
28- Declare decision about termsOnly the fixed term
was tested p0.0028 lt a 0.05 - Reject H0 ? extra sleep depends on drug
administered - We did a 2 way ANOVA, also known as a paired
t-test. - 1 random factor
- 1 fixed factor with 2 levels
29- Declare decision about terms
- Paired t-test
- Calculate difference within each random category
- Test if the mean diff differs from zero
A B A-B fits res
0.7 1.9 1.2 1.58 -0.38
-1.6 0.8 2.4 1.58 0.82
-0.2 1.1 1.3 1.58 -0.28
-1.2 0.1 1.3 1.58 -0.28
-0.1 -0.1 0.0 1.58 -1.58
3.4 4.4 1.0 1.58 -0.58
3.7 5.5 1.8 1.58 0.22
0.8 1.6 0.8 1.58 -0.78
0.0 4.6 4.6 1.58 3.02
2.0 3.4 1.4 1.58 -0.18
p0.0028
30- Report and interpret parameters of biological
interest Means per drug, not controlled for
among subject variation
SE LCL (5) UCL(95)
mean(TA)0.75 hs 0.5657 -0.53 hs 2.03 hs
mean(TB)2.33 hs 0.6332 0.89 hs 3.76 hs
Confidence limits for the average difference,
controlled for among subject variation
SE LCL (5) UCL(95)
mean(TB-TA)1.58 hs 0.388 0.7 hs 2.46 hs
31(No Transcript)
32Quizz 7Good luck!
Clock