






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
In the traditional analysis of variance (ANOVA) F-test, we are testing the null hypothesis ... the p-value for the Permutation F-test.
Typology: Exercises
1 / 12
This page cannot be seen from the preview
Don't miss anything!







H 0 : τ 1 = τ 2 = · · · = τk
against the alternative hypothesis
H 1 : τi 6 = τj for some i 6 = j.
That is, if H 1 is true, then all treatment effects are not equal.
SStrt/(k − 1) SSE/(N − k)
M Strt M SE
where N = kb the total number of observations in the data set.
SST otal = SST rt + SSBlock + SSE
SST otal =
∑^ k
i=
∑^ b
j=
y^2 ij −
y^2 ·· kb
SST rt =
∑^ k
i=
y^2 i· b
y^2 ·· kb
SSBlock =
∑^ b
j=
y^2 ·j k
y ··^2 kb
SSE = SST otal − SST rt − SSBlock where
y^2 ·· kb
is the correction factor.
Dot notation: y·· = the sum of all of the responses, yi· = sum of responses for treatment i, and y·j = sum of responses for block j.
The Steps in the Permutation F -Test (Monte-Carlo Approach)
R code for Permutation F-Test for RCBD
library(lmPerm)
y <- c(120,208,199,194,177,195,207,188,181,164,155,175, 122,137,177,177,160,138,128,128,160,142,157,179)
treatment <- c(1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4) block <- c(rep(c(1,2,3,4,5,6),4))
treatment <- as.factor(treatment) block <- as.factor(block)
rcbd <- data.frame(y,block,treatment)
summary(aov(y~treatment+block,rcbd))
summary(aovp(y~treatment+block,rcbd))
R output for Permutation F-Test for RCBD
> # Parametric F-test for a RCBD
Df Sum Sq Mean Sq F value Pr(>F) <-- P-value for the treatment 3 5408 1802.8 3.121 0.0575. <-- parametric F-Test block 5 2817 563.4 0.975 0. Residuals 15 8664 577.
Signif. codes: 0 ‘’ 0.001 ‘’ 0.01 ‘’ 0.05 ‘.’ 0.1 ‘ ’ 1
> # Permutation Test for RCBD
Df R Sum Sq R Mean Sq Iter Pr(Prob) <-- P-value for the treatment 3 5408.3 1802.78 1848 0.07251. <-- Permutation F-Test block 5 2816.8 563.37 573 0. Residuals 15 8664.2 577.
Signif. codes: 0 ‘’ 0.001 ‘’ 0.01 ‘’ 0.05 ‘.’ 0.1 ‘ ’ 1
Example of Page’s Test (from Table 4.5.2 in Introduction to Modern Nonparametric Statistics
by J. Higgins).
The researchers wanted to test the null hypothesis of identical results against the alternative
that blind children tend to score lower than blindfolded children, and that blindfolded children
tend to score lower than seeing children.
R code for Cochran’s Q Test Example
library(statmod) library(doBy) library(ade4) library(RVAideMemoire)
y <- c(1,0,0,0, 1,1,1,1, 0,0,0,0, 0,1,1,1, 1,1,1,1, 1,0,0,1, 1,0,1,1, 1,0,0,1, 1,0,0,0, 1,0,0,0, 1,1,1,1)
blocks <- c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7, 8,8,8,8,9,9,9,9,10,10,10,10,11,11,11,11)
treatment <- c(rep(c("MajOp","ActPIP","SubjPIP","SemiPIP"),11))
cochran.qtest(y~treatment|blocks,alpha=.05,p.method="fdr")
SAS code for Cochran’s Q Test Example
*** Cochran’s Q Test Example ***; ********************************;
*** Analysis by entering ranks within blocks ***;
DATA in; DO patient = 1 TO 11; DO treatment = ’MajOp’, ’ActP ’, ’SubjP’, ’SemiP’; INPUT y @@; OUTPUT; END; END; CARDS; 1 0 0 0 1 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 1 1 0 1 1 1 0 0 1 1 0 0 0 1 0 0 0 1 1 1 1 ; PROC FREQ DATA=in; TABLE patienttreatmenty / NOPRINT CMH; TITLE ’Cochran’’s Q Test’; RUN;
SAS output for Cochran’s Q Test
Cochran’s Q Test
The FREQ Procedure
Summary Statistics for treatment by y Controlling for patient
Cochran-Mantel-Haenszel Statistics (Based on Table Scores)
1 Nonzero Correlation 1 0.0261 0. 2 Row Mean Scores Differ 3 7.6957 0.0527 <--- 3 General Association 3 7.6957 0.
Total Sample Size = 44
R code for Permutation Test for Cochran’s Q
R output for Permutation Test for Cochran’s Q
> # Permutation Test for Cochran’s Q
> sum(Cvec) [1] 25 > N <- sum(Rvec) [1] 25
> Qdenom [1] 23 > Qnumer [1] 177
> # Cochran’s Q Test Statistic for Observed Data
> Q0 [1] 7.
> # Calculate p-value [1] 0.
R code for Permutation Test for Cochran’s Q
library(gtools)
Prep = 50000