Learn R Programming

permuco (version 1.1.0)

Pmat: Create a set of permutations.

Description

Compute a permutation matrix used as argument in aovperm, lmperm, clusterlm functions. The first column represents the identity permutation.

Usage

Pmat(np = 5000, n, type = "default")

Arguments

np

A numeric value for the number of permutations. Default is 5000.

n

A numeric value for the number of observations.

type

A character string to specify the type of matrix. See Details.

Value

A matrix n x np containing the permutations/coinflips. First permutation is the identity.

Details

type can set to : "default" : np random with replacement permutations among the n! permutations. "all" : all n! possible permutations.

Examples

Run this code
# NOT RUN {
## data
data("emergencycost")

## Create a set of 2000 permutations
set.seed(42)
pmat = Pmat(np = 2000, n = nrow(emergencycost))

## centrering the covariate to the mean
emergencycost$LOSc <- scale(emergencycost$LOS, scale = FALSE)

## ANCOVA
mod_cost_0 <- aovperm(cost ~ LOSc*sex*insurance, data = emergencycost, np = 2000)
mod_cost_1 <- aovperm(cost ~ LOSc*sex*insurance, data = emergencycost, P = pmat)
mod_cost_2 <- aovperm(cost ~ LOSc*sex*insurance, data = emergencycost, P = pmat)

## Same p-values for both models 1 and 2 but differents of model 0
mod_cost_0
mod_cost_1
mod_cost_2

# }

Run the code above in your browser using DataLab