t2p(npc) |
R Documentation |
This function provides a
matrix of partial p-values from the related multivariate null distribution
matrix.
t2p(T)
|
an array/vector
containing the permutation null distribution of the partial tests. The first
dimension (length) is always equal to |
A matrix P
of p-values with dimension equal to
dim(T).
## Example on producing plastic film from Krzanowski (1998, p. 381)
## Two sample problem with three (dependent) variables. Partial tests are required with one-sided alternatives.
n1<-9
n2<-11
n<-n1+n2
tear <- c(6.5, 6.2, 5.8, 6.5, 6.5, 6.9, 7.2, 6.9, 6.1, 6.3,
6.7, 6.6, 7.2, 7.1, 6.8, 7.1, 7.0, 7.2, 7.5, 7.6)
gloss <- c(9.5, 9.9, 9.6, 9.6, 9.2, 9.1, 10.0, 9.9, 9.5, 9.4,
9.1, 9.3, 8.3, 8.4, 8.5, 9.2, 8.8, 9.7, 10.1, 9.2)
opacity <- c(4.4, 6.4, 3.0, 4.1, 0.8, 5.7, 2.0, 3.9, 1.9, 5.7,
2.8, 4.1, 3.8, 1.6, 3.4, 8.4, 5.2, 6.9, 2.7, 1.9)
Y <- cbind(tear, gloss, opacity)
X <- c(rep(1/n1,n1),rep(-1/n2,n2))
# X: vector of contrasts: the test statistics is the difference of sampling means for all variables
A= c(1,1,-1)
# array specifying the alternatives (“greater” for ‘tear’ and ‘gloss’, “less” for ‘opacity’
source("permute.r")
source("combine.r")
source("t2p.r")
set.seed(3)
T<-permute(X,Y,A,B=1000)
dim(T)
# [1] 1001 3
P<-t2p(T)
P[1,]
# [1] 0.994 0.014 0.252 # partial p-values;
par(mfrow=c(1,p)) # data representation;
for(j in 1:p){boxplot(Y[,j]~X,main=colnames(Y)[j],names=c("Sample2","Sample1"))}
T1 <- combine(P,fun="Fisher",which=2,W=c(0.5,0.2,0.3))
dim(T1)
#[1] 1001 1
global.p <- t2p(T1)[1]
global.p
# [1] 0.248 # global p-value.