R/perm.test.R
perm.test-methods.Rd
Two-sample permutation test for differences in the population means
Two-sample permutation test for differences in the population means
Analysis of variance based on permutation tests
# Default S3 method
perm.test(
x,
y,
nsim = 1000,
seed = NULL,
alternative = c("two.sided", "less", "greater"),
...
)
# S3 method for class 'formula'
perm.test(
formula,
data,
nsim = 1000,
seed = NULL,
alternative = c("two.sided", "less", "greater"),
...
)
# S3 method for class 'aov'
perm.test(object, nsim = 1000, seed = NULL, ...)
a (non-empty) numeric vector of data values.
a (non-empty) numeric vector of data values.
number of permutations to be simulated
seed passed to the random number generator; if NULL (default), then a random seed is used
a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less". You can specify just the initial letter.
further arguments passed to or from other methods.
a formula of the form lhs ~ rhs where lhs is a numeric variable giving the data values and rhs either 1 for a one-sample or paired test or a factor with two levels giving the corresponding groups.
an optional matrix or data frame containing the variables in the formula formula. By default the variables are taken from environment(formula).
an object of class aov
perm.test returns an object of class perm.test containing information regarding the permutation test carried out.
perm.test returns an object of class perm.test containing information regarding the permutation test carried out.
perm.test returns an object of class perm.test.aov containing information regarding the permutation test carried out
The permutation test implemented here is based on the difference of the sample means.
The permutation test implemented here is based on the difference of the sample means.
# \donttest{
library(planex)
library(tidyr)
data(catalisadores2)
t.test <- t.test(catalisadores2$C1, catalisadores2$C2)
t.test
#>
#> Welch Two Sample t-test
#>
#> data: catalisadores2$C1 and catalisadores2$C2
#> t = -0.35359, df = 13.353, p-value = 0.7292
#> alternative hypothesis: true difference in means is not equal to 0
#> 95 percent confidence interval:
#> -3.387118 2.432118
#> sample estimates:
#> mean of x mean of y
#> 92.2550 92.7325
#>
#perm <- perm.test(catalisadores2$C1, catalisadores2$C2, nsim = 1000, seed = 123)
#perm$pvalor
# }
# \donttest{
library(planex)
library(tidyr)
data(catalisadores2)
#catalisadores2 <- catalisadores2 %*%
# pivot_longer(
# cols = 1:2,
# names_to = "catalisador",
# values_to = "rendimento"
# )
# t.test <- t.test(rendimento ~ catalisador, data=catalisadores2)
# t.test
# perm <- perm.test(rendimento ~ catalisador, data=catalisadores2, nsim = 1000, seed = 123)
# perm$pvalor
# }
# \donttest{
library(planex)
data(refrigerantes)
mod <- aov(desvio ~ carbonatacao*pressao*velocidade, data=refrigerantes)
summary(mod)
#> Df Sum Sq Mean Sq F value Pr(>F)
#> carbonatacao 2 252.75 126.38 178.412 1.19e-09 ***
#> pressao 1 45.38 45.38 64.059 3.74e-06 ***
#> velocidade 1 22.04 22.04 31.118 0.00012 ***
#> carbonatacao:pressao 2 5.25 2.62 3.706 0.05581 .
#> carbonatacao:velocidade 2 0.58 0.29 0.412 0.67149
#> pressao:velocidade 1 1.04 1.04 1.471 0.24859
#> carbonatacao:pressao:velocidade 2 1.08 0.54 0.765 0.48687
#> Residuals 12 8.50 0.71
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
perm <- perm.test(mod)
summary(perm)
#>
#> Permutation tests based on 1000 replications
#> df statistic p.valor
#> carbonatacao 2 178.4118 <2e-16 ***
#> pressao 1 64.0588 <2e-16 ***
#> velocidade 1 31.1176 0.001 ***
#> carbonatacao:pressao 2 3.7059 0.056 .
#> carbonatacao:velocidade 2 0.4118 0.667
#> pressao:velocidade 1 1.4706 0.262
#> carbonatacao:pressao:velocidade 2 0.7647 0.492
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# }