Generate a constraint matrix with a predefined structure

constrMat(n, type = c("monotone", "control", "average", "laverage",
  "uaverage", "caverage"), base = 1)

Arguments

n

a (possibly named) vector of sample sizes for each group

type

character string defining the type of constraints; one of "monotone", "control","average","laverage","uaverage", or "caverage"

base

column of the constraint matrix representing a control group (when type = "control")

Value

a constraint matrix

See also

orlm, constrSet

Examples

n <- c(10,20,30,40) constrMat(n, type="monotone")
#> 1 2 3 4 #> [1,] -1 1 0 0 #> [2,] 0 -1 1 0 #> [3,] 0 0 -1 1
constrMat(n, type="control", base=2)
#> 1 2 3 4 #> [1,] 1 -1 0 0 #> [2,] 0 -1 1 0 #> [3,] 0 -1 0 1
constrMat(n, type="average")
#> 1 2 3 4 #> [1,] -1.0000000 0.2222222 0.3333333 0.4444444 #> [2,] -0.3333333 -0.6666667 0.4285714 0.5714286 #> [3,] -0.1666667 -0.3333333 -0.5000000 1.0000000
constrMat(n, type="laverage")
#> 1 2 3 4 #> [1,] -1.0000000 1.0000000 0.0 0 #> [2,] -0.3333333 -0.6666667 1.0 0 #> [3,] -0.1666667 -0.3333333 -0.5 1
constrMat(n, type="uaverage")
#> 1 2 3 4 #> [1,] -1 0.2222222 0.3333333 0.4444444 #> [2,] 0 -1.0000000 0.4285714 0.5714286 #> [3,] 0 0.0000000 -1.0000000 1.0000000
constrMat(n, type="caverage", base=2)
#> 1 2 3 4 #> [1,] 1.000 -1 0.000 0.0 #> [2,] 0.250 -1 0.750 0.0 #> [3,] 0.125 -1 0.375 0.5