contr.custom: Build a custom contrast and k-2 orthogonal ones

Description Usage Arguments Value Author(s) Examples

View source: R/functions.R

Description

Creates a set of contrast codes that are orthogonal to a given one with the aim of testing the given contrast in a linear model

Usage

1

Arguments

cont

vector of contrast weight (numeric).

Value

a data.frame with k-1 contrast codes, with k=length(cont). It can be used to assing contrast weights using contrasts

Author(s)

Marcello Gallucci, mcfanda@gmail.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
### sim some data
cont<-c(-3,-1,1,3)
means<-c(10,12,10,12)
y<-rep(means,1000)+rnorm(4000,0,2)
x<-factor(rep(1:4,1000))
### assign contrast weights
contrasts(x)<-contr.custom(cont)
contrasts(x)
cor(contr.custom(cont))
summary(lm(y~x))

mcfanda/cpower documentation built on May 28, 2019, 1 p.m.