Download presentation
Presentation is loading. Please wait.
Published byHoward Brown Modified over 9 years ago
1
Exercise 1 You have a clinical study in which 10 patients will either get the standard treatment or a new treatment Randomize which 5 of the 10 get the new treatment so that all possible combinations can result. Use Excel or R or another formal randomization method. Instead, randomize so that in each pair of patients entered by date, one has the standard and one the new treatment (blocked randomization). What are the advantages of each method? Why is randomization important? April 2, 2013SPH 247 Statistical Analysis of Laboratory Data1
2
Exercise 1 Solutions For the first situation, using Excel, you can (for example) put the numbers 1–10 in column A, put five “Treatment” and five “Standard” in column B, put =rand() in column C. Then fix the numbers in column C and sort columns B and C by the random numbers. For the second situation, you can put random numbers in column B and fix them, then in cell C2 (assuming a header row) put =IF(B2<B3,"A","B") and in cell C3 put =IF(B3<B2,"A","B"). Then copy the pair of cells to C4, C6, C8, and C10. Or use “Treatment” and “Standard” instead of “A” and “B”. There are many other ways to do this. April 2, 2013SPH 247 Statistical Analysis of Laboratory Data2
3
April 2, 2013SPH 247 Statistical Analysis of Laboratory Data3 PatientRandomTreatment 10.015712A 20.555195A 30.131912A 40.691906A 50.12621A 60.563621B 70.237196B 80.08503B 90.80344B 100.107165B PatientRandomTreatment 10.015712A 20.08503B 30.107165B 40.12621A 50.131912A 60.237196B 70.555195A 80.563621B 90.691906A 100.80344B Before SortingAfter Sorting
4
April 2, 2013SPH 247 Statistical Analysis of Laboratory Data4 PatientRandomTreatment 10.2285A 20.470443B 30.939263B 40.106693A 50.41447A 60.504649B 70.491129A 80.628083B 90.796861B 100.167474A IF(C2<C3,"A","B") IF(C3<C2,"A","B") IF(C4<C5,"A","B") IF(C5<C4,"A","B") IF(C6<C7,"A","B") IF(C7<C6,"A","B") IF(C8<C9,"A","B") IF(C9<C8,"A","B") IF(C10<C11,"A","B") IF(C11<C10,"A","B")
5
Comments Randomization is important to avoid bias, approximately balance covariates, and provide a basis for analysis. Blocked randomization can better control for time effects, but this particular version risks unblinding the next patient. April 2, 2013SPH 247 Statistical Analysis of Laboratory Data5
6
Exercise 2 Analyze the testosterone levels from Rosner’s endocrin data set in the same way as we did for the estradiol levels, using anova(lm()) Reanalyze estradiol and testosterone using lme() and verify that the results are the same. Here is the specification lme(Testosterone ~ 1, random = ~1 | Subject,data=endocrin) Repeat the analysis of the coop data for specimens 2 and 5 separately. Do the analysis both with the traditional ANOVA tables using lm() and with lme() and compare the results April 2, 2013SPH 247 Statistical Analysis of Laboratory Data6
7
April 2, 2013SPH 247 Statistical Analysis of Laboratory Data7 > anova(lm(Testosterone ~ Subject,data=endocrin)) Analysis of Variance Table Response: Testosterone Df Sum Sq Mean Sq F value Pr(>F) Subject 4 571.66 142.915 22.041 0.002246 ** Residuals 5 32.42 6.484 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Replication error variance is 6.484, so the standard deviation of replicates is 2.55 pg/mL This compared to average levels across subjects from 15.55 to 36.25 Estimated variance across subjects is (142.915 − 6.484)/2 = 68.2155 Standard deviation across subjects is 8.26 pg/mL If we average the replicates, we get five values, the standard deviation of which is 8.45. This contains both the subject and replication variance.
8
April 2, 2013SPH 247 Statistical Analysis of Laboratory Data8 > lme(Estradiol ~ 1, random = ~1 | Subject,data=endocrin) Linear mixed-effects model fit by REML Data: endocrin Log-restricted-likelihood: -28.41785 Fixed: Estradiol ~ 1 (Intercept) 14.99 Random effects: Formula: ~1 | Subject (Intercept) Residual StdDev: 8.434606 2.458254 Number of Observations: 10 Number of Groups: 5 > lme(Testosterone ~ 1, random = ~1 | Subject,data=endocrin) Linear mixed-effects model fit by REML Data: endocrin Log-restricted-likelihood: -28.51958 Fixed: Testosterone ~ 1 (Intercept) 25.3 Random effects: Formula: ~1 | Subject (Intercept) Residual StdDev: 8.259258 2.546372 Number of Observations: 10 Number of Groups: 5
9
Specimen 2 > anova(lm(Conc ~ Lab + Lab:Bat,data=coop,sub=Spc=="S2")) Analysis of Variance Table Response: Conc Df Sum Sq Mean Sq F value Pr(>F) Lab 5 4.6640 0.93280 150.52 4.947e-14 *** Lab:Bat 12 1.3951 0.11626 18.76 9.484e-08 *** Residuals 18 0.1115 0.00620 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data9 The test for batch-in-lab is correct, but the test for lab is not—the denominator should be The Lab:Bat MS, so F(5,12) = 0.93280/0.11626 = 8.0234 so p = 0.00157, still significant The residual variance is 0.00620 (sd=0.0787). The estimated batch variance within labs is (0.11626 −0.00620)/2 = 0.05503 (sd = 0.2346). The estimated lab variance is (0.93280 − 0.11626)/(3×2) = 0.13609 (sd = 0.3689)
10
> lme(Conc ~1, random = ~1 | Lab/Bat,sub=Spc=="S2",data=coop) Linear mixed-effects model fit by REML Data: coop Subset: Spc == "S2" Log-restricted-likelihood: 7.383694 Fixed: Conc ~ 1 (Intercept) 0.3658333 Random effects: Formula: ~1 | Lab (Intercept) StdDev: 0.3689019 Formula: ~1 | Bat %in% Lab (Intercept) Residual StdDev: 0.2345892 0.07872243 Number of Observations: 36 Number of Groups: Lab Bat %in% Lab 6 18 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data10 The standard deviations for Lab, Batch, and Residual exactly match those from the lm() analysis
11
Specimen 5 > anova(lm(Conc ~ Lab + Lab:Bat,data=coop,sub=Spc=="S5")) Analysis of Variance Table Response: Conc Df Sum Sq Mean Sq F value Pr(>F) Lab 5 16.3277 3.2655 33.7688 1.539e-08 *** Lab:Bat 12 7.2049 0.6004 6.2088 0.0003072 *** Residuals 18 1.7406 0.0967 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data11 The test for batch-in-lab is correct, but the test for lab is not—the denominator should be The Lab:Bat MS, so F(5,12) = 3.2655/0.6004 = 5.4389 so p = 0.00766, still significant The residual variance is 0.0967 (sd=0.3110). The estimated batch variance within labs is (0.6004 −0.0967)/2 = 0.2519 (sd = 0.5018). The estimated lab variance is (3.2655 − 0.6004)/(3×2) = 0.4442 (sd = 0.6665)
12
> lme(Conc ~1, random = ~1 | Lab/Bat,sub=Spc=="S5",data=coop) Linear mixed-effects model fit by REML Data: coop Subset: Spc == "S5" Log-restricted-likelihood: -30.32728 Fixed: Conc ~ 1 (Intercept) 7.761389 Random effects: Formula: ~1 | Lab (Intercept) StdDev: 0.6664803 Formula: ~1 | Bat %in% Lab (Intercept) Residual StdDev: 0.5018488 0.3109703 Number of Observations: 36 Number of Groups: Lab Bat %in% Lab 6 18 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data12 The standard deviations for Lab, Batch, and Residual exactly match those from the lm() analysis
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.