make.mon.ui: Function for creating the matrix ui for monotonicity...

View source: R/make.mon.ui.R

make.mon.uiR Documentation

Function for creating the matrix ui for monotonicity (in)equality restrictions

Description

Function make.mon.ui creates the matrix ui for a factor, depending on its coding.

Usage

make.mon.ui(x, type = "coeff", contr = NULL)

Arguments

x

an R factor (in case of type = "coeff") or the dimension of the multivariate normal distribution (in case of type = "mean")

type

the situation for which ui is needed: can be coeff for coefficients in a linear model or mean for the expectation vector of a multivariate normal distribution

contr

relevant in case of type = "coeff" only, ignored otherwise;
the contrast with which x is coded;
if the contrasts attribute of x is a character string, contr = NULL uses this character string, otherwise contr = NULL is identical to contr = "contr.treatment".

Explicit choices for contr can be any of contr.treatment, contr.SAS, contr.diff and contr.sum) (must be given in quotes).
The other generally-available codings (contr.helmert and contr.poly) do not easily permit conclusions about monotonicity.
If the value for contr is not compatible with the factors coding, an error is thrown.

Details

The function determines the matrix ui as needed for the functions in packge ic.infer, when a monotone increase from first to last level of the x is under investigation (type = "coeff") or when a monotone increase among the components of the expectation vector is investigated (type = "mean"). The respective monotone decrease can be accomodated by -make.mon.ui().

If the coding of the factor x is explicitly given, the function throws an error if the actual coding does not correspond to the specified value of contr.

Care is needed when using make.mon.ui with a linear model: It is the users responsibility to make sure that the coding used in the model corresponds to the coding used in make.mon.ui.

Value

a square matrix with as many rows and columns as there are dummy variables for the factor

Author(s)

Ulrike Groemping, BHT Berlin

See Also

See also contrasts for how to apply contrasts, contrast for the available contrasts in package stats, contr.diff for the specific monotonicity contrast function from this package.

Examples

gifte <- boot::poisons    ## gifte is German for poisons
## default: contr.treatment (with default base 1)
linmod <- lm(1/time~poison+treat, gifte)
summary(orlm(linmod, ui=make.mon.ui(gifte$poison), index=2:3))

## next: contr.diff
contrasts(gifte$poison) <- "contr.diff" 
linmod <- lm(1/time~poison+treat, gifte)
summary(orlm(linmod, ui=make.mon.ui(gifte$poison), index=2:3))

## next: contr.SAS
contrasts(gifte$poison) <- "contr.SAS"
linmod <- lm(1/time~poison+treat, gifte)
summary(orlm(linmod, ui=make.mon.ui(gifte$poison), index=2:3))

## next: contr.sum
contrasts(gifte$poison) <- "contr.sum"
linmod <- lm(1/time~poison+treat, gifte)
summary(orlm(linmod, ui=make.mon.ui(gifte$poison), index=2:3))



ic.infer documentation built on Oct. 5, 2023, 5:09 p.m.