Вы находитесь на странице: 1из 8

Sample Data from RCB Experiment

Introduction
Presentation Title Goes Here to R:
Data Manipulation
…presentation and Statistical analysis
subtitle.
Save data in comma
delimited format

Analysis of Variance

Violeta I. Bartolome
Senior Associate Scientist
Crop Research Informatics Laboratory
International Rice Research Institute

Import file to R

mydata <- read.table(


“RCBdata.csv", # name of csv file
sep = ",", # separator
header = TRUE)
factor () Factor
• factor() is used to encode a vector as • A vector object used to specify a
a factor discrete classification (grouping) of the
• Example components of other vectors of the
same length
• Two types of factor
o Unordered – levels are binary or nominal
o Ordered – levels are quantitative

forward back

levels() aov()

• provides access to the levels • Fit an analysis of variance model


attribute of a variable. • Usage
• Usage: aov(formula, data = NULL)
levels(x) # returns the value of the levels • formula
levels(x) <- value # sets the attribute response ~ mean.formula + Error(strata.formula)
• Example • Model for an RCB single factor design:
Defining ANOVA Models
aov()
• a+b # additive effects of a and b
• RCB factorial design • a:b # interaction between a and b

• a*b # same as a + b + a:b

• Split-plot design • ^n # includes all interactions up to level n

Ex. (a+b+c)^2 is identical to


• Split-split-plot design a + b + c + a:b + a:c + b:c
• b%in%a # effects of b are nested in a

a/b # identical to a+a:b


• Strip-plot design
• a-b # removes the effect of b

Ex. y~x-1 forces a model without an intercept

summary () residuals()

• generic function used to produce • generic function which extracts


summaries of the results of various model residuals from objects
model fitting functions returned by modeling functions
• Example: • Example:
predict() coef()

• generic function for predictions from • generic function which extracts


the results of various model fitting model coefficients from objects
functions returned by modeling functions
• Example • Example

df.residual() deviance()

• Returns the residual degrees-of- • Returns the deviance or residual sum


freedom extracted from a fitted of squares of a fitted model object
model object • Example
• Example
Residual plot
names()

• Function to list the elements in an


object
• Example

Comparing treatment means

• Using agricolae package


library (agricolae)
LSD.test (y, # response variable
trt, # variable whose levels
# are to be compared
DFerror, # error df
MSerror, # Mean Square of error
alpha = 0.05, # level of sig
group=TRUE, # TRUE or FALSE
main = NULL) # Title
HSD.test() can be use if number of treatments is 6 or more.
Bar Graph with mean comparison Split-plot

Source of Variation df
Block r-1
Factor A (A) a-1
Error (a) (r-1)(a-1)
Factor B (B) b-1
AxB (a-1)(b-1)
Error (b) a(r-1)(b-1)
Total rab-1

ANOVA for Split-plot Design SEDs for Split-plot


Type of pair comparison
sed t-value
Number Between

1 Two main-plot means


2E a tinv(α, dfa )
(averaged over all subplot
rb
Error (a) treatments)
2 Two subplot means
2E b tinv ( α, df b )
(averaged over all main-plot
treatments) ra
3 Two subplot means at the 2E b
tinv ( α, df b )
same main-plot treatment
Error (b) r
4 Two main-plot means at the 2[(b−1)E b +E a ]
same or different subplot tinv ( α, df ab )
rb
treatment
Degrees of freedom and Error MS
Satterthwaite degrees of freedom

dfab =
[Ea + (b − 1) Eb ]2
2
Ea [(b − 1) Eb ]
2
+
dfa dfb

ANOVA for Strip plot design


Strip-plot

Source of Variation df
Block r-1
Horizontal Factor (H) h-1
Error(a)
Error (a) (r-1)(h-1)
Vertical Factor (V) v-1
Error (b) (r-1)(v-1)
Error(b)
HxV (h-1)(v-1)
Error (c) (r-1)(h-1)(v-1)
Total rhv-1
Error(c)
Satterthwaite degrees of
SEDs for Strip-plot
freedom
Type of pair comparison
sed t-value
df ac =
[Ea + (b − 1) Ec ]2
2
Ea [(b − 1) Ec ]
Number Between 2
+
1 Two horizontal means
df a df c
2E a
(averaged over all vertical tinv ( α, df a )
treatments) rb
2 Two vertical means
2E b tinv ( α, df b )
[Eb + (a − 1) Ec]
dfbc = 2
2

(averaged over all horizontal


Eb [(a − 1) Ec]
ra 2
treatments)
3 Two vertical means at the 2[(a −1)E c + E b ]
+
same horizontal treatment ra
tinv ( α, df bc ) dfb dfc
4 Two horizontal means at the
2[(b −1)E c + E a ]
same vertical treatment tinv ( α, df ac )
rb

Degrees of freedom and EMS

Вам также может понравиться