Learn R Programming

predictmeans (version 1.0.6)

permmodels: Permutation Test of Linear Model

Description

This function provides permutation t-tests for coefficients of (fixed) effects and permutation F-tests for the terms in a linear model such as aov, lm, glm, gls, lme, and lmer.

Usage

permmodels(model, data, block=NULL, group=NULL, covariate=NULL, nsim=4999, check=FALSE, 
  exact=FALSE, fo=NULL, prt=TRUE, seed)

Value

The function produces permutation t-test table for coefficients of (fixed) effects, permutation ANOVA table for model terms and a model parameter list permlist, a list containing nsim=4999 times permutation refitted model parameters which are used in functions predictmeans and contrastmeans.

Arguments

model

Model object returned by aov, lm, glm, gls, lme, and lmer.

data

Data object used in the model fitting.

block

Name (in "quotes") for the blocking factor in the data.

group

Name (in "quotes") for the group factor in the data.

covariate

Name(s) (in "quotes") for the covariate variable(s) in the model.

nsim

The number of permutations. The default is 4999.

check

a logical variable to indicate whether or not you want to check permutation results, the default is FALSE.

exact

A logical variable to indicate whether or not exact no. of permutations will be used (applicable only to free the permutation case). The default is FALSE.

fo

A model formula used in the model; fo!=NULL when the formula is specified by function formula.

prt

A logical variable to indicate whether or not to print output on the screen. The default is TRUE.

seed

Specify a random number generator seed, for reproducible results.

Author

Dongwen Luo, Siva Ganesh and John Koolaard

Examples

Run this code
## Not run for simplifying process of submiting pkg to CRAN
#library(predictmeans)
#Oats$nitro <- factor(Oats$nitro) 
#fm <- lme(yield ~ nitro*Variety, random=~1|Block/Variety, data=Oats)
## library(lme4)
## fm <- lmer(yield ~ nitro*Variety+(1|Block/Variety), data=Oats)
#
## Permutation Test for model terms
#system.time(
#  permlme <- permmodels(model=fm, data=Oats, block="Block", group="Variety", nsim=999)
#)  
#
## Permutation Test for multiple comparisons
#predictmeans(model=fm, modelterm="nitro:Variety", atvar="Variety", adj="BH", 
#  permlist=permlme, plot=FALSE)
#
## Permutation Test for specified contrasts
#cm <- rbind(c(-1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0), 
#            c(0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0))
#contrastmeans(model=fm, modelterm="nitro:Variety", ctrmatrix=cm, permlist=permlme)

Run the code above in your browser using DataLab