Download presentation
Presentation is loading. Please wait.
Published byConrad Harrison Modified over 9 years ago
1
Part IV The General Linear Model. Multiple Explanatory Variables Chapter 13.3 Fixed *Random Effects Paired t-test
2
Overview of GLM GLM RegressionANOVAANCOVAOne-Way ANOVATwo-Way ANOVA Simple regression Multiple regression Two categories (t-test) Multiple categories - Fixed (e.g., treatment, age) - Random (e.g., subjects, litters) 2 fixed factors 1 fixed & 1 random (e.g., Paired t-test) Multi-Way ANOVA
3
GLM: Paired t-test Two factors (2 explanatory variables on a nominal scale) One fixed (2 categories) The other random (many categories) + Fixed factor Random factor Remove var. among units → sensitive test
4
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? GLM | Paired t-test SubjectDrugADrug B 10.71.9 2-1.60.8 3-0.21.1 4-1.20.1 5-0.1 63.44.4 73.75.5 80.81.6 90.04.6 102.03.4 Data are means
5
1. Construct Model Response variable: T=hours of extra sleep – ratio scale Explanatory variables: 1. Drug. X D = Drug A, Drug B. Nominal scale Fixed effect 2. Subject. X S = [1,2,…,10]. Nominal scale Random effect Mean value for each subject varies randomly and is not under the control of the investigator
6
1. Construct Model Verbal: Hours of extra sleep depends on drug. Graphical:
7
1. Construct Model Verbal: Hours of extra sleep depends on drug. Graphical:
8
1. Construct Model Verbal: Hours of extra sleep depends on drug. Graphical:
9
1. Construct Model Formal: Can we have an interaction term? Let’s look at the df df Drug = df Subject = df Drug*Subject = Df residual =
10
1. Construct Model Verbal: Hours of extra sleep depends on drug. Graphical:
11
1. Construct Model Formal: Revised Model:
12
2. Execute analysis lm1 <- lm(T~XS+XD, data=sleep) XSTXD 10.7A 2-1.6A 3-0.2A 4-1.2A 5-0.1A 63.4A 73.7A 80.8A 90.0A 102.0A 11.9B 20.8B 31.1B 40.1B 5-0.1B 64.4B 75.5B 81.6B 94.6B 103.4B R: multiple ways to model random effects Instead of lm: lmer{lme4} lme{nlme} use aov(), specifying Error(subject)
13
2. Execute analysis 1.Compute 2.Compute mean per drug mean (T D=A )= 0.75 hs 3.Compute drug effect 4. Compute mean per subject mean(T S=1 )= 1.3 hs 5. Compute subject effect 6. Compute fits 7. Compute residualsresiduals = T - fits
14
2. Execute analysis XSTXD β0β0 βDβD βSβS fitsres 10.7A1.54-0.79-0.240.51-0.19 2-1.6A1.54-0.79-1.94-1.190.41 3-0.2A1.54-0.79-1.09-0.34-0.14 4-1.2A1.54-0.79-2.09-1.34-0.14 5-0.1A1.54-0.79-1.64-0.89-0.79 11.9B1.540.79-0.242.090.19 20.8B1.540.79-1.940.39-0.41 31.1B1.540.79-1.091.240.14 40.1B1.540.79-2.090.240.14 5-0.1B1.540.79-1.640.690.79
15
3. Evaluate model □ Straight line model ok? □ Errors homogeneous? □ Errors normal? □ Errors independent?
16
3. Evaluate model □ Straight line model ok? □ Errors homogeneous? □ Errors normal? □ Errors independent? NA
17
3. Evaluate model □ Straight line model ok? □ Errors homogeneous? □ Errors normal? □ Errors independent? NA
18
3. Evaluate model □ Straight line model ok? □ Errors homogeneous? □ Errors normal? □ Errors independent? NA
19
4.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
5.Decide on mode of inference. Is hypothesis testing appropriate? 6.State H A / H o 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
6.State H A / H o pair, test statistic, distribution, tolerance for Type I error. Test Statistic Distribution of test statitstic Tolerance for Type I error
22
7. ANOVA n = 20 SourcedfSSMSFp Subject Drug Res______ Total
23
7. ANOVA n = 20 SourcedfSSMSFp Subject958.078 Drug112.482 Res___9___6.808 Total1977.37
24
7. ANOVA n = 20 SourcedfSSMSFp Subject958.0786.453 Drug112.48212.48 Res___9___6.8080.7564 Total1977.37
25
7. ANOVA n = 20 SourcedfSSMSFp Subject958.0786.453 Drug112.48212.4816.50.0028 Res___9___6.8080.7564 Total1977.37
26
7. ANOVA n = 20 SourcedfSSMSFp Subject958.0786.453 Drug112.48212.4816.50.0028 Res___9___6.8080.7564 Total1977.37 SourcedfSSMSFp Drug112.48 3.46260.079 Res__18__64.8863.6048 Total1977.37 BUT we did this before Ch 10.2 2 sample t-test STATISTICAL CONTROL r 2 = 0.91 r 2 = 0.16
27
8. Decide whether to recompute p-value Slight deviation from normality n<30, p=0.0028 not near α no need to recompute
28
9.Declare decision about terms Only the fixed term was tested p=0.0028 < α =0.05 Reject H 0 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
9.Declare decision about terms ABA-Bfitsres 0.71.91.21.58-0.38 -1.60.82.41.580.82 -0.21.11.31.58-0.28 -1.20.11.31.58-0.28 -0.1 0.01.58-1.58 3.44.41.01.58-0.58 3.75.51.81.580.22 0.81.60.81.58-0.78 0.04.6 1.583.02 2.03.41.41.58-0.18 Paired t-test: 1.Calculate difference within each random category 2.Test if the mean diff differs from zero p=0.0028
30
10.Report and interpret parameters of biological interest Means per drug, not controlled for among subject variation SELCL (5%)UCL(95%) mean(T A )=0.75 hs0.5657-0.53 hs2.03 hs mean(T B )=2.33 hs0.63320.89 hs3.76 hs Confidence limits for the average difference, controlled for among subject variation SELCL (5%)UCL(95%) mean(T B -T A )=1.58 hs 0.3880.7 hs2.46 hs
32
Quizz 7 Good luck! Clock
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.