cmratioiacov: Contrast objects for treatment comparison over a grid of...

Description Usage Arguments Details Value Author(s) Examples

Description

Compute contrast object for pairwise comparisons of treatment levels over grids of covariates given a fitted model object of class 'lm' or 'glm', such that it is suitable for further use in function gsci.ratio, package mratios. Restricted to ONE factor variable and pairwise comparisons of treatments ("Dunnett", "Tukey", or user defined subsets of Tukey-type comparisons). More than one covariate, quadratic terms etc. are possible.

Usage

1
cmratioiacov(modelfit, treatment, treatcon = "Dunnett", covset, ...)

Arguments

modelfit

a fitted model of class "lm" or "glm", right hand side of the model formula should contain one factor variable, and one (or several) covariate(s), etc.

treatment

a single character string, identifying the factor variable in the model

treatcon

either a list of two matrices with integer entries, or a single character string. If a list of two matrices: number of columns must be = number of treatment levels in the factor variable; rows correspond to comparisons between treatments: only coefficients 1,0 are allowed, all contrasts must define pairwise treatment differences; if a character string: only "Dunnett" or "Tukey" are currently allowed, these will be passed to the type-argument in contrMatRatio (package mratios)

covset

a named list with numeric vectors: names of list elements must be the names of the covariates in the model, vector in each element is supposed to contain the covariate values at which contrasts sould be computed

...

further arguments to be passed to internal functions, currently only: base a single integer indicating the control level, if treatcon is a character string, passed to contrMat digits a single integer, defining the number of visible non-zero digits when rounding covariate values in contrast names

Details

Based on the call and data set in the object modelfit, matrices are contructed that allow to compute predictions over the grid of covariate values specified in covset and the factor variable specified in treatment. These matrices are then combined to define pairwise differences between the levels in treatment, over the grid of covariate values. The type (or set) of pairwise differences can be defined in the argument treatcon.

Value

A list with items

numC

matrix of linear combinations of model parameters that define the model predictions to appear in the numerator of the multiple ratios

denC

matrix of linear combinations of model parameters that define the model predictions to appear in the denominator of the multiple ratios

rnames

vector of names for the comparisons defined by numC and denC

dataratio

a data set with names for the ratios, the treatment levels contributing in numerator and denominator of the ratios, and the covariate(s); rows of the data set are ordered as are the rows in the numerator and denominator matrices, denC and numC

Xpos

model matrix for those predictions used as minuend to compute linfct

Xneg

model matrix for those predictions used as subtrahend to compute linfct

datapos
dataneg

Author(s)

Frank Schaarschmidt

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
data(pc)

fitPC<-lm(yield ~ x + I(x^2) + additive + additive:I(x^2), data=pc)

anova(fitPC)

# estimate the ratio of model predictions over a grid of covariates,
# where the covariate x takes vales 1,2,3,...9
# and the ratios of additive S1 to control and S2 to control
# are of interest (Dunnett-type-comparisons)

cmrpc <- cmratioiacov(fitPC, treatment="additive",
   covset=list("x" = seq(from=1, to=9, by=1)), treatcon="Dunnett")

str(cmrpc, max.level=1)

# numerator and denominator matrices for plug-in in gsci.ratio
str(cmrpc$denC)
str(cmrpc$numC)

# a vector of names for the comparisons
str(cmrpc$rnames)

# a data set containing names of comparisons, treatment levels
# contributing and covariate values(for later use in plotting)
str(cmrpc$dataratio)

# alternatively, the between-treatment-ratios of interest can be
# defined as a list in the format of ?contrMatRatio
# Note that columns correspond to treatment levels
# as defined in the current definition of the treatment variable

levels(pc$additive)

# numC: matrix indicating  treatments in numerator,
# denC: indicating treatments in denominator 

cmUser<-list(
numC=rbind(
"S1/control"=c(0,1,0),
"S2/control"=c(0,0,1),
"S2/S1"=c(0,0,1)),

denC=rbind(
"S1/control"=c(1,0,0),
"S2/control"=c(1,0,0),
"S2/S1"=c(0,1,0))
)

cmUser

# this matrix can be suplied into the argument treatcon:

cmrpcUser <- cmratioiacov(fitPC, treatment="additive",
   covset=list("x" = seq(from=1, to=9, by=1)), treatcon=cmUser)

str(cmrpcUser, max.level=1)

# linear combinations of model predcitions for the numerators
str(cmrpcUser$numC)

# linear combinations of model predcitions for the denominators
str(cmrpcUser$denC)

schaarschmidt/statintcov documentation built on May 29, 2019, 3:26 p.m.