Workshop 9.3a: Randomized block designs

Similar documents
Workshop 9.1: Mixed effects models

Stat 5303 (Oehlert): Randomized Complete Blocks 1

Mixed Model: Split plot with two whole-plot factors, one split-plot factor, and CRD at the whole-plot level (e.g. fancier split-plot p.

R Output for Linear Models using functions lm(), gls() & glm()

Repeated measures, part 2, advanced methods

Hierarchical Random Effects

Introduction and Background to Multilevel Analysis

These slides illustrate a few example R commands that can be useful for the analysis of repeated measures data.

Stat 5303 (Oehlert): Balanced Incomplete Block Designs 1

20. REML Estimation of Variance Components. Copyright c 2018 (Iowa State University) 20. Statistics / 36

Mixed Model Theory, Part I

Exploring Hierarchical Linear Mixed Models

Outline. Mixed models in R using the lme4 package Part 3: Longitudinal data. Sleep deprivation data. Simple longitudinal data

Hierarchical Linear Models (HLM) Using R Package nlme. Interpretation. 2 = ( x 2) u 0j. e ij

lme4 Luke Chang Last Revised July 16, Fitting Linear Mixed Models with a Varying Intercept

Stat 579: Generalized Linear Models and Extensions

A Handbook of Statistical Analyses Using R 2nd Edition. Brian S. Everitt and Torsten Hothorn

Repeated measures, part 1, simple methods

Subject-specific observed profiles of log(fev1) vs age First 50 subjects in Six Cities Study

STAT3401: Advanced data analysis Week 10: Models for Clustered Longitudinal Data

Correlated Data: Linear Mixed Models with Random Intercepts

CO2 Handout. t(cbind(co2$type,co2$treatment,model.matrix(~type*treatment,data=co2)))

Outline. Statistical inference for linear mixed models. One-way ANOVA in matrix-vector form

Mixed effects models

A brief introduction to mixed models

Random and Mixed Effects Models - Part II

A Handbook of Statistical Analyses Using R 2nd Edition. Brian S. Everitt and Torsten Hothorn

Lecture 9 STK3100/4100

Workshop 7.4a: Single factor ANOVA

Random and Mixed Effects Models - Part III

Mixed models in R using the lme4 package Part 2: Longitudinal data, modeling interactions

SPH 247 Statistical Analysis of Laboratory Data

Solution pigs exercise

A Handbook of Statistical Analyses Using R. Brian S. Everitt and Torsten Hothorn

Statistical Analysis of Hierarchical Data. David Zucker Hebrew University, Jerusalem, Israel

Analysis of binary repeated measures data with R

Simulation and Analysis of Data from a Classic Split Plot Experimental Design

Value Added Modeling

#Alternatively we could fit a model where the rail values are levels of a factor with fixed effects

Introduction to the Analysis of Hierarchical and Longitudinal Data

Multi-factor analysis of variance

13. October p. 1

over Time line for the means). Specifically, & covariances) just a fixed variance instead. PROC MIXED: to 1000 is default) list models with TYPE=VC */

STK4900/ Lecture 10. Program

Week 8, Lectures 1 & 2: Fixed-, Random-, and Mixed-Effects models

Multiple Predictor Variables: ANOVA

dm'log;clear;output;clear'; options ps=512 ls=99 nocenter nodate nonumber nolabel FORMCHAR=" = -/\<>*"; ODS LISTING;

Non-Gaussian Response Variables

Odor attraction CRD Page 1

STAT 572 Assignment 5 - Answers Due: March 2, 2007

Coping with Additional Sources of Variation: ANCOVA and Random Effects

Lecture 22 Mixed Effects Models III Nested designs

Temporal Learning: IS50 prior RT

Introduction to SAS proc mixed

Topic 17 - Single Factor Analysis of Variance. Outline. One-way ANOVA. The Data / Notation. One way ANOVA Cell means model Factor effects model

Power analysis examples using R

Randomized Block Designs with Replicates

Homework 3 - Solution

Outline. Example and Model ANOVA table F tests Pairwise treatment comparisons with LSD Sample and subsample size determination

Analysis of Covariance

Introduction to SAS proc mixed

Non-independence due to Time Correlation (Chapter 14)

Intruction to General and Generalized Linear Models

Time-Series Regression and Generalized Least Squares in R*

Multiple Regression: Example

Outline for today. Two-way analysis of variance with random effects

Simple Linear Regression

ST430 Exam 2 Solutions

PAPER 206 APPLIED STATISTICS

Statistical Inference: The Marginal Model

unadjusted model for baseline cholesterol 22:31 Monday, April 19,

MODELS WITHOUT AN INTERCEPT

Aedes egg laying behavior Erika Mudrak, CSCU November 7, 2018

UNIVERSITY OF TORONTO. Faculty of Arts and Science APRIL 2010 EXAMINATIONS STA 303 H1S / STA 1002 HS. Duration - 3 hours. Aids Allowed: Calculator

Solution Anti-fungal treatment (R software)

SAS Syntax and Output for Data Manipulation: CLDP 944 Example 3a page 1

Wheel for assessing spinal block study

Mixed models in R using the lme4 package Part 7: Generalized linear mixed models

Multiple Predictor Variables: ANOVA

SAS Syntax and Output for Data Manipulation:

Longitudinal Data Analysis

Longitudinal Data Analysis. with Mixed Models

17. Example SAS Commands for Analysis of a Classic Split-Plot Experiment 17. 1

Fitting mixed models in R

WITHIN-PARTICIPANT EXPERIMENTAL DESIGNS

T-test: means of Spock's judge versus all other judges 1 12:10 Wednesday, January 5, judge1 N Mean Std Dev Std Err Minimum Maximum

Topic 20: Single Factor Analysis of Variance

FACTORIAL DESIGNS and NESTED DESIGNS

Answer to exercise: Blood pressure lowering drugs

The linear mixed model: introduction and the basic model

Recall that a measure of fit is the sum of squared residuals: where. The F-test statistic may be written as:

Stat 5102 Final Exam May 14, 2015

Figure 1: The fitted line using the shipment route-number of ampules data. STAT5044: Regression and ANOVA The Solution of Homework #2 Inyoung Kim

36-463/663: Hierarchical Linear Models

Mixed models in R using the lme4 package Part 5: Generalized linear mixed models

Contrasting Marginal and Mixed Effects Models Recall: two approaches to handling dependence in Generalized Linear Models:

ANOVA Longitudinal Models for the Practice Effects Data: via GLM

22s:152 Applied Linear Regression. Returning to a continuous response variable Y...

Booklet of Code and Output for STAC32 Final Exam

Multivariate Statistics in Ecology and Quantitative Genetics Summary

Transcription:

-1- Workshop 93a: Randomized block designs Murray Logan November 23, 16 Table of contents 1 Randomized Block (RCB) designs 1 2 Worked Examples 12 1 Randomized Block (RCB) designs 11 RCB design Simple Randomized block design 12 RCB design y ij = µ + β i + α j + ε ij µ - the mean of the first treatment group

-2- β - the random (Block) effect α - the main within Block effect eg abundance = base + block + treatment 13 Repeated measures designs 0 0 T0 00 00 0 0 T0 00 00 0 0 T0 00 00 0 0 T0 00 00 14 Assumptions Normality, homogeneity of variance No Block by within-block interaction

-3- Q4 Q1 Q4 Q1 Q3 Q3 Q4 Q3 Q2 Q2 Q1 Q2 0 0 0 0 T0 T0 00 00 00 00 Q4 Q3 Q1 Q2 Q3 Q4 Q1 Q2 Q4 Q2 Q1 Q3 0 0 0 0 T0 T0 00 00 00 00 15 Assumptions Normality, homogeneity of variance No Block by within-block interaction Independence (variance-covariance structure) 16 Var-cov structure T1 T2 T3 T4 T1 015 000 000 000 T2 000 015 000 000 T3 000 000 015 000 T4 000 000 000 015 T1 T2 T3 T4 Block B Block A T1 T2 T3 T4 Block D Block C T1 T2 T3 T4 T1 015 005 005 005 T2 005 015 005 005 T3 005 005 015 005 T4 005 005 005 015 Subject C Subject B Subject A T1 T2 T3 T4 T1 015 060 030 010 T2 060 015 060 030 T3 030 060 015 060 T4 010 030 060 015 10 30 40 Time (mins)

-4-17 Assumptions Normality, homogeneity of variance No Block by within-block interaction Independence (variance-covariance structure) RCB - usually met Repeated measures - rarely met 18 Example > datarcb1 <- readcsv('/data/datarcb1csv', stripwhite=true) > head(datarcb1) y A Block 1 3739761 A B1 2 6147033 B B1 3 7807370 C B1 4 3059803 A B2 5 5900035 B B2 6 7672575 C B2 19 Exploratory data analysis Normality and homogeneity of variance > boxplot(y~a, datarcb1) 40 60 80 100 A B C 110 Exploratory data analysis No block by within-block interaction

-5- > library(ggplot2) > ggplot(datarcb1, aes(y=y, x=a, group=block,color=block)) + + geom_line() + + guides(color=guide_legend(ncol=3)) 100 Block B1 B B31 B10 B21 B32 80 B11 B12 B22 B23 B33 B34 B13 B24 B35 y B14 B25 B4 60 B15 B16 B26 B27 B5 B6 B17 B28 B7 B18 B29 B8 40 B19 B2 B3 B30 B9 A B C A 111 Exploratory data analysis No block by within-block interaction > library(car) > residualplots(lm(y~block+a, datarcb1)) Pearson residuals 5 0 5 Pearson residuals 5 0 5 B1 B14 B19 B23 B28 B32 B5 B9 Block A B C A Pearson residuals 5 0 5 40 60 80 100 Fitted values Test stat Pr(> t ) Block NA NA A NA NA Tukey test -0885 0376

-6-112 Sphericity > library(nlme) > datarcb1lme <- lme(y~a, random=~1 Block, + data=datarcb1) > acf(resid(datarcb1lme)) Series resid(datarcb1lme) ACF 04 02 00 02 04 06 08 10 0 5 10 15 Lag 113 Model fitting > #Assuming sphericity > datarcb1lme <- lme(y~a, random=~1 Block, data=datarcb1, + method='reml') > datarcb1lme1 <- lme(y~a, random=~a Block, data=datarcb1, + method='reml') > AIC(datarcb1lme, datarcb1lme1) df AIC datarcb1lme 5 7221087 datarcb1lme1 10 72701 > anova(datarcb1lme, datarcb1lme1) Model df AIC BIC loglik Test LRatio p-value datarcb1lme 1 5 7221087 7352336-3560544 datarcb1lme1 2 10 72701 7534499-3536001 1 vs 2 4908574 04271 114 Model fitting > #Assuming sphericity > datarcb1lmear1 <- lme(y~a, random=~1 Block, data=datarcb1, + correlation=corar1(),method='reml') > datarcb1lme1ar1 <- lme(y~a, random=~a Block, data=datarcb1, + correlation=corar1(),method='reml') > AIC(datarcb1lme, datarcb1lme1,datarcb1lmear1, datarcb1lme1ar1)

-7- df AIC datarcb1lme 5 7221087 datarcb1lme1 10 72701 datarcb1lmear1 6 7233178 datarcb1lme1ar1 11 72901 > anova(datarcb1lme, datarcb1lme1,datarcb1lmear1, datarcb1lme1ar1) Model df AIC BIC loglik Test LRatio p-value datarcb1lme 1 5 7221087 7352336-3560544 datarcb1lme1 2 10 72701 7534499-3536001 1 vs 2 4908574 04271 datarcb1lmear1 3 6 7233178 7390676-3556589 2 vs 3 4117606 03903 datarcb1lme1ar1 4 11 72901 7580748-3536001 3 vs 4 4117606 05326 115 Model validation > plot(datarcb1lme) 2 Standardized residuals 1 0 1 40 60 80 100 Fitted values > plot(resid(datarcb1lme, type='normalized') ~ + datarcb1$a) resid(datarcb1lme, type = "normalized") 1 0 1 2 A B C datarcb1$a 116 Effects plots > library(effects) > plot(effect('a',datarcb1lme))

-8- A effect plot 80 70 y 60 50 40 A B C A 117 Parameter estimates > summary(datarcb1lme) Linear mixed-effects model fit by REML Data: datarcb1 AIC BIC loglik 7221087 7352336-3560544 Random effects: Formula: ~1 Block (Intercept) Residual StdDev: 1151409 4572284 Fixed effects: y ~ A Value StdError DF t-value p-value (Intercept) 4303434 94074 68 55053 0 AB 2845241 1092985 68 2603185 0 AC 4015556 1092985 68 3673936 0 Correlation: (Intr) AB AB -0261 AC -0261 0500 Standardized Within-Group Residuals: Min Q1 Med Q3 Max -178748258-057867597 -007108159 049990644 233727672 Number of Observations: 105 Number of Groups: 35

-9-118 Parameter estimates > intervals(datarcb1lme) Approximate 95% confidence intervals Fixed effects: lower est upper (Intercept) 3885568 4303434 4721300 AB 2627140 2845241 3063343 AC 3797455 4015556 4233658 attr(,"label") [1] "Fixed effects:" Random Effects: Level: Block lower est upper sd((intercept)) 8964236 1151409 1478925 Within-group standard error: lower est upper 3864944 4572284 5409077 119 Parameter estimates > VarCorr(datarcb1lme) Block = pdlogchol(1) Variance StdDev (Intercept) 13257434 11514093 Residual 90578 4572284 1 ANOVA table > anova(datarcb1lme) numdf dendf F-value p-value (Intercept) 1 68 10893799 <0001 A 2 68 7140295 <0001 121 R 2 [1] 06516126 [1] 0300933 [1] 004745443 [1] 09525456

-10-122 What about lmer? > library(lme4) > datarcb1lmer <- lmer(y~a+(1 Block), data=datarcb1, REML=TRUE, + control=lmercontrol(checknobsvsnre="ignore")) > datarcb1lmer1 <- lmer(y~a+(a Block), data=datarcb1, REML=TRUE, + control=lmercontrol(checknobsvsnre="ignore")) > AIC(datarcb1lmer, datarcb1lmer1) df AIC datarcb1lmer 5 7221087 datarcb1lmer1 10 72701 > anova(datarcb1lmer, datarcb1lmer1) Data: datarcb1 Models: datarcb1lmer: y ~ A + (1 Block) datarcb1lmer1: y ~ A + (A Block) Df AIC BIC loglik deviance Chisq Chi Df Pr(>Chisq) datarcb1lmer 5 72903 74230-35951 71903 datarcb1lmer1 10 73398 76052-35699 71398 50529 5 04095 123 What about lmer? > summary(datarcb1lmer) Linear mixed model fit by REML ['lmermod'] Formula: y ~ A + (1 Block) Data: datarcb1 Control: lmercontrol(checknobsvsnre = "ignore") REML criterion at convergence: 7121 Scaled residuals: Min 1Q Median 3Q Max -178748-057868 -007108 049991 233728 Random effects: Groups Name Variance StdDev Block (Intercept) 13257 11514 Residual 91 4572 Number of obs: 105, groups: Block, 35 Fixed effects: Estimate Std Error t value (Intercept) 43034 94 55 AB 28452 1093 2603 AC 40156 1093 3674 Correlation of Fixed Effects: (Intr) AB AB -0261 AC -0261 0500

-11-124 What about lmer? > anova(datarcb1lmer) Analysis of Variance Table Df Sum Sq Mean Sq F value A 2 29855 14927 71403 125 What about lmer? > # Perform SAS-like p-value calculations (requires the lmertest and pbkrtest package) > library(lmertest) > datarcb1lmer <- update(datarcb1lmer) > summary(datarcb1lmer) Linear mixed model fit by REML t-tests use Satterthwaite approximations to degrees of freedom [ lmermod] Formula: y ~ A + (1 Block) Data: datarcb1 Control: lmercontrol(checknobsvsnre = "ignore") REML criterion at convergence: 7121 Scaled residuals: Min 1Q Median 3Q Max -178748-057868 -007108 049991 233728 Random effects: Groups Name Variance StdDev Block (Intercept) 13257 11514 Residual 91 4572 Number of obs: 105, groups: Block, 35 Fixed effects: Estimate Std Error df t value Pr(> t ) (Intercept) 43034 94 40930 55 <2e-16 *** AB 28452 1093 68000 2603 <2e-16 *** AC 40156 1093 68000 3674 <2e-16 *** --- Signif codes: 0 '***' 0001 '**' 001 '*' 005 '' 01 ' ' 1 Correlation of Fixed Effects: (Intr) AB AB -0261 AC -0261 0500 126 What about lmer? > anova(datarcb1lmer) # Satterthwaite denominator df method Analysis of Variance Table of type III with Satterthwaite approximation for degrees of freedom Sum Sq Mean Sq NumDF DenDF Fvalue Pr(>F) A 29855 14927 2 68 71403 < 22e-16 *** --- Signif codes: 0 '***' 0001 '**' 001 '*' 005 '' 01 ' ' 1

-12- > anova(datarcb1lmer,ddf="kenward-roger") # Kenward-Roger denominator df method Analysis of Variance Table Df Sum Sq Mean Sq F value A 2 29855 14927 71403 2 Worked Examples Worked Examples