Presentation is loading. Please wait.

Presentation is loading. Please wait.

SPH 247 Statistical Analysis of Laboratory Data 1April 2, 2013SPH 247 Statistical Analysis of Laboratory Data.

Similar presentations


Presentation on theme: "SPH 247 Statistical Analysis of Laboratory Data 1April 2, 2013SPH 247 Statistical Analysis of Laboratory Data."— Presentation transcript:

1 SPH 247 Statistical Analysis of Laboratory Data 1April 2, 2013SPH 247 Statistical Analysis of Laboratory Data

2 ANOVA—Fixed and Random Effects We will review the analysis of variance (ANOVA) and then move to random and fixed effects models Nested models are used to look at levels of variability (days within subjects, replicate measurements within days) Crossed models are often used when there are both fixed and random effects. April 2, 2013SPH 247 Statistical Analysis of Laboratory Data2

3 The Basic Idea The analysis of variance is a way of testing whether observed differences between groups are too large to be explained by chance variation One-way ANOVA is used when there are k ≥ 2 groups for one factor, and no other quantitative variable or classification factor. April 2, 2013SPH 247 Statistical Analysis of Laboratory Data3

4 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data4 ABC

5 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data5 Data = Grand Mean + Column Deviations from grand mean + Cell Deviations from column mean Are the column deviations from the grand mean too big to be accounted for by the cell deviations from the column means?

6 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data6 ABC Data

7 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data7 ABC Column Means

8 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data8 ABC Deviations from Column Means

9 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data9 red.cell.folate package:ISwR R Documentation Red cell folate data Description: The 'folate' data frame has 22 rows and 2 columns. It contains data on red cell folate levels in patients receiving three different methods of ventilation during anesthesia. Format: This data frame contains the following columns: folate: a numeric vector. Folate concentration (μg/l). ventilation: a factor with levels: 'N2O+O2,24h': 50% nitrous oxide and 50% oxygen, continuously for 24~hours; 'N2O+O2,op': 50% nitrous oxide and 50% oxygen, only during operation; 'O2,24h': no nitrous oxide, but 35-50% oxygen for 24~hours.

10 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data10 > data(red.cell.folate) > help(red.cell.folate) > summary(red.cell.folate) folate ventilation Min. :206.0 N2O+O2,24h:8 1st Qu.:249.5 N2O+O2,op :9 Median :274.0 O2,24h :5 Mean : rd Qu.:305.5 Max. :392.0 > attach(red.cell.folate) > plot(folate ~ ventilation)

11 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data11

12 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data12 > folate.lm <- lm(folate ~ ventilation) > summary(folate.lm) Call: lm(formula = folate ~ ventilation) Residuals: Min 1Q Median 3Q Max Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) e-14 *** ventilationN2O+O2,op * ventilationO2,24h Signif. codes: 0 `***' `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 Residual standard error: on 19 degrees of freedom Multiple R-Squared: , Adjusted R-squared: F-statistic: on 2 and 19 DF, p-value:

13 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data13 > anova(folate.lm) Analysis of Variance Table Response: folate Df Sum Sq Mean Sq F value Pr(>F) ventilation * Residuals Signif. codes: 0 `***' `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1

14 Two- and Multi-way ANOVA If there is more than one factor, the sum of squares can be decomposed according to each factor, and possibly according to interactions One can also have factors and quantitative variables in the same model (cf. analysis of covariance) All have similar interpretations April 2, 2013SPH 247 Statistical Analysis of Laboratory Data14

15 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data15 Heart rates after enalaprilat (ACE inhibitor) Description: 36 rows and 3 columns. data for nine patients with congestive heart failure before and shortly after administration of enalaprilat, in a balanced two-way layout. Format: hr a numeric vector. Heart rate in beats per minute. subj a factor with levels '1' to '9'. time a factor with levels '0' (before), '30', '60', and '120' (minutes after administration).

16 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data16 > data(heart.rate) > attach(heart.rate) > heart.rate hr subj time

17 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data17 > plot(hr~subj) > plot(hr~time) > hr.lm <- lm(hr~subj+time) > anova(hr.lm) Analysis of Variance Table Response: hr Df Sum Sq Mean Sq F value Pr(>F) subj e-16 *** time * Residuals Signif. codes: 0 `***' `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 > sres <- resid(lm(hr~subj)) > plot(sres~time) Note that when the design is orthogonal, the ANOVA results don’t depend on the order of terms.

18 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data18

19 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data19

20 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data20

21 Fixed and Random Effects A fixed effect is a factor that can be duplicated (dosage of a drug) A random effect is one that cannot be duplicated Patient/subject Repeated measurement There can be important differences in the analysis of data with random effects The error term is always a random effect April 2, 2013SPH 247 Statistical Analysis of Laboratory Data21

22 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data22

23 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data23

24 Estradiol data from Rosner 5 subjects from the Nurses’ Health Study One blood sample each Each sample assayed twice for estradiol (and three other hormones) The within variability is strictly technical/assay Variability within a person over time will be much greater April 2, 2013SPH 247 Statistical Analysis of Laboratory Data24

25 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data25

26 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data26 > anova(lm(Estradiol ~ Subject,data=endocrin)) Analysis of Variance Table Response: Estradiol Df Sum Sq Mean Sq F value Pr(>F) Subject ** Residuals Signif. codes: 0 ‘***’ ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Replication error variance is 6.043, so the standard deviation of replicates is 2.46 pg/mL This compared to average levels across subjects from 8.05 to Estimated variance across subjects is ( − 6.043)/2 = Standard deviation across subjects is 8.43 pg/mL If we average the replicates, we get five values, the standard deviation of which is also 71.1

27 Fasting Blood Glucose Part of a larger study that also examined glucose tolerance during pregnancy Here we have 53 subjects with 6 tests each at intervals of at least a year The response is glucose as mg/100mL April 2, 2013SPH 247 Statistical Analysis of Laboratory Data27

28 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data28 > anova(lm(FG ~ Subject,data=fg2)) Analysis of Variance Table Response: FG Df Sum Sq Mean Sq F value Pr(>F) Subject e-09 *** Residuals Signif. codes: 0 ‘***’ ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 > Estimated within-Subject variance is , so the standard deviation is 8.48 mg/100mL Estimated between-Subject variance is ( − )/6 = , sd = 4.80 mg/100mL The variance of the 53 means is 35.05, which is larger because it includes a component of the within-subject variance

29 Nested Random Effects Models Cooperative trial with 6 laboratories, one analyte (7 in the full data set), 3 batches per lab (a month apart), and 2 replicates per batch Estimate the variance components due to labs, batches, and replicates Test for significance if possible Effects are lab, batch-in-lab, and error April 2, 2013SPH 247 Statistical Analysis of Laboratory Data29

30 Analysis using lm or aov April 2, 2013SPH 247 Statistical Analysis of Laboratory Data30 > anova(lm(Conc ~ Lab + Lab:Bat,data=coop2)) Analysis of Variance Table Response: Conc Df Sum Sq Mean Sq F value Pr(>F) Lab e-10 *** Lab:Bat * Residuals 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) = / = so p = 3.47e-4, still significant Residual Batch Lab

31 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data31

32 Analysis using lme R package nlme Two separate formulas, one for the fixed effects and one for the random effects In this case, no fixed effects Nested random effects use the / notation lme(Conc ~1, random = ~1 | Lab/Bat,data=coop2) April 2, 2013SPH 247 Statistical Analysis of Laboratory Data32

33 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data33 lme(Conc ~1, random = ~1 | Lab/Bat,data=coop2) Linear mixed-effects model fit by REML Data: coop2 Log-restricted-likelihood: Fixed: Conc ~ 1 (Intercept) Random effects: Formula: ~1 | Lab (Intercept) StdDev: Formula: ~1 | Bat %in% Lab (Intercept) Residual StdDev: Number of Observations: 36 Number of Groups: Lab Bat %in% Lab 6 18 Average Concentration SD of Labs SD of Batches and Replicates

34 Hypothesis Tests When data are balanced, one can compute expected mean squares, and many times can compute a valid F test. In more complex cases, or when data are unbalanced, this is more difficult One requirement for certain hypothesis tests to be valid is that the null hypothesis value is not on the edge of the possible values For H 0 : α = 0, we have that α could be either positive or negative For H 0 : σ 2 = 0, negative variances are not possible April 2, 2013SPH 247 Statistical Analysis of Laboratory Data34

35 April 2, 2013SPH 247 Statistical Analysis of Laboratory Data35 EffectVarianceSD Residual Batch Lab The variance among replicates a month apart ( = ) is about twice that of those on the same day ( ), and the standard deviations are and These are CV’s on the average of 21% and 16% respectively The variance among values from different labs is about , with a standard deviation of and a CV of about 33%

36 More complex models When data are balanced and the expected mean squares can be computed, this is a valid way for testing and estimation Programs like lme and lmer in R and Proc Mixed in SAS can handle complex models But most likely this is a time when you may need to consult an expert April 2, 2013SPH 247 Statistical Analysis of Laboratory Data36


Download ppt "SPH 247 Statistical Analysis of Laboratory Data 1April 2, 2013SPH 247 Statistical Analysis of Laboratory Data."

Similar presentations


Ads by Google