Description Usage Arguments Details Value Author(s) References See Also Examples
conTest
tests linear equality and/or inequality
restricted hypotheses for linear models.
1 2 
object 
an object of class OR an object of class 
constraints 
there are two ways to constrain parameters.
First, the constraint syntax consists of one or more textbased
descriptions, where the syntax can be specified as a literal
string enclosed by single quotes. Only the names of Second, the constraint syntax consists of a matrix R (or a vector in
case of one constraint) and defines the lefthand side of the
constraint Rθ ≥ rhs, where each row represents one
constraint. The number of columns needs to correspond to the
number of parameters estimated (θ) by model. The rows
should be linear independent, otherwise the function gives an
error. For more information about constructing the matrix R and
rhs see the details in the 
type 
hypothesis test type "A", "B", "C", "global", or "summary" (default). See details for more information. 
test 
test statistic; for information about the nulldistribution see details.

rhs 
vector on the righthand side of the constraints; Rθ ≥ rhs. The length of this vector equals the number of rows of the constraints matrix R and consists of zeros by default. Note: only used if constraints input is a matrix or vector. 
neq 
integer (default = 0) treating the number of
constraints rows as equality constraints instead of inequality
constraints. For example, if 
... 
futher options for the 
The following hypothesis tests are available:
Type A: Test H0: all constraints with equalities ("=") active against HA: at least one inequality restriction (">") strictly true.
Type B: Test H0: all constraints with inequalities (">") (including some equalities ("=")) active against HA: at least one restriction false (some equality constraints may be maintained).
Type C: Test H0: at least one restriction false ("<") against HA: all constraints strikty true (">"). This test is based on the intersectionunion principle (Silvapulle and Sen, 2005, chp 5.3). Note that, this test only makes sense in case of no equality constraints.
Type global: equal to Type A but H0 contains additional equality constraints. This test is analogue to the global Ftest in lm, where all coefficients but the intercept equal 0.
The nulldistribution of hypothesis test Type C is based on a tdistribution (onesided). Its power can be poor in case of many inequalty constraints. Its main role is to prevent wrong conclusions from significant results from hypothesis test Type A.
The exact finite sample distributions of the nonrobust F, score and LRtest statistics based on restricted OLS estimates and normally distributed errors, are a mixture of Fdistributions under the null hypothesis (Wolak, 1987). For the robust tests, we found that the results based on these mixtures of Fdistributions approximate the tail probabilities better than their asymptotic distributions.
Note that, in case of equality constraints only, the nulldistribution of the (non)robust Ftest statistics are based on an Fdistribution. The (non)robust Wald and (non)robust scoretest statistics are based on chisquare distributions.
If object is of class lm
or rlm
, the conTest
function
internally calls the restriktor
function. Arguments for the
restriktor
function can be passed on via the ...
. Additional
arguments for the conTest
function can also passed on via the ...
.
See for example conTestF
for all available arguments.
An object of class conTest, for which a print is available. More specifically, it is a list with the following items:
CON 
a list with useful information about the constraints. 
Amat 
constraints matrix. 
bvec 
vector of righthand side elements. 
meq 
number of equality constraints. 
meq.alt 
same as input neq.alt. 
iact 
number of active constraints. 
type 
same as input. 
test 
same as input. 
Ts 
teststatistic value. 
df.residual 
the residual degrees of freedom. 
pvalue 
tail probability for 
b.eqrestr 
equality restricted regression coefficients.
Only available for 
b.unrestr 
unrestricted regression coefficients. 
b.restr 
restricted regression coefficients. 
b.restr.alt 
restricted regression coefficients under HA if some equality constraints are maintained. 
Sigma 
variancecovariance matrix of unrestricted model. 
R2.org 
unrestricted Rsquared. 
R2.reduced 
restricted Rsquared. 
boot 
same as input. 
model.org 
original model. 
Leonard Vanbrabant and Yves Rosseel
Robertson, T., Wright, F.T. and Dykstra, R.L. (1988). Order Restricted Statistical Inference New York: Wiley.
Shapiro, A. (1988). Towards a unified theory of inequalityconstrained testing in multivariate analysis. International Statistical Review 56, 49–62.
Silvapulle, M. (1992a). Robust tests of inequality constraints and onesided hypotheses in the linear model. Biometrika, 79, 621–630.
Silvapulle, M. (1992b). Robust WaldType Tests of OneSided Hypotheses in the Linear Model. Journal of the American Statistical Association, 87, 156–161.
Silvapulle, M. and Silvapulle, P. (1995). A score test against onesided alternatives. American statistical association, 90, 342–349.
Silvapulle, M. (1996) On an Ftype statistic for testing onesided hypotheses and computation of chibarsquared weights. Statistics & probability letters, 28, 137–141.
Silvapulle, M. (1996) Robust bounded influence tests against onesided hypotheses in general parametric models. Statistics & probability letters, 31, 45–50.
Silvapulle, M.J. and Sen, P.K. (2005). Constrained Statistical Inference. Wiley, New York
Wolak, F. (1987). An exact test for multiple inequality and equality constraints in the linear regression model. Journal of the American statistical association, 82, 782–793.
quadprog,
conTest
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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141  ## example 1:
# the data consist of ages (in months) at which an
# infant starts to walk alone.
# prepare data
DATA1 < subset(ZelazoKolb1972, Group != "Control")
# fit unrestricted linear model
fit1.lm < lm(Age ~ 1 + Group, data = DATA1)
# the variable names can be used to impose constraints on
# the corresponding regression parameters.
coef(fit1.lm)
# constraint syntax: assuming that the walking
# exercises would not have a negative effect of increasing the
# mean age at which a child starts to walk.
myConstraints1 < ' GroupActive < GroupPassive;
GroupPassive < GroupNo '
conTest(fit1.lm, myConstraints1)
# another way is to first fit the restricted model
fit.restr1 < restriktor(fit1.lm, constraints = myConstraints1)
conTest(fit.restr1)
## Not run:
# Or in matrix notation.
Amat1 < rbind(c(1, 0, 1),
c( 0, 1, 1))
myRhs1 < rep(0L, nrow(Amat1))
myNeq1 < 0
conTest(fit1.lm, constraints = Amat1,
rhs = myRhs1, neq = myNeq1)
## End(Not run)
#########################
## Artificial examples ##
#########################
# generate data
n < 10
means < c(1,2,1,3)
nm < length(means)
group < as.factor(rep(1:nm, each = n))
y < rnorm(n * nm, rep(means, each = n))
DATA2 < data.frame(y, group)
# fit unrestricted linear model
fit2.lm < lm(y ~ 1 + group, data = DATA2)
coef(fit2.lm)
## example 2: increasing means
myConstraints2 < ' group1 < group2
group2 < group3
group3 < group4 '
# compute Ftest for hypothesis test Type A and compute the tail
# probability based on the parametric bootstrap. We only generate 9
# bootstrap samples in this example; in practice you may wish to
# use a much higher number.
conTest(fit2.lm, constraints = myConstraints2, type = "A",
boot = "parametric", R = 9)
# or fit restricted linear model
fit2.con < restriktor(fit2.lm, constraints = myConstraints2)
conTest(fit2.con)
## Not run:
# increasing means in matrix notation.
Amat2 < rbind(c(1, 1, 0, 0),
c( 0,1, 1, 0),
c( 0, 0,1, 1))
myRhs2 < rep(0L, nrow(Amat2))
myNeq2 < 0
conTest(fit2.con, constraints = Amat2, rhs = myRhs2, neq = myNeq2,
type = "A", boot = "parametric", R = 9)
## End(Not run)
## example 3: equality constraints only.
myConstraints3 < ' group1 == group2
group2 == group3
group3 == group4 '
conTest(fit2.lm, constraints = myConstraints3)
# or
fit3.con < restriktor(fit2.lm, constraints = myConstraints3)
conTest(fit3.con)
## example 4:
# combination of equality and inequality constraints.
myConstraints4 < ' group1 == group2
group3 < group4 '
conTest(fit2.lm, constraints = myConstraints4, type = "B", neq.alt = 1)
# fit resticted model and compute modelbased bootstrapped
# standard errors. We only generate 9 bootstrap samples in this
# example; in practice you may wish to use a much higher number.
# Note that, a warning message may be thrown because the number of
# bootstrap samples is too low.
fit4.con < restriktor(fit2.lm, constraints = myConstraints4,
se = "boot.model.based", B = 9)
conTest(fit4.con, type = "B", neq.alt = 1)
## example 5:
# restriktor can also be used to define effects using the := operator
# and impose constraints on them. For example, is the
# average effect (AVE) larger than zero?
# generate data
n < 30
b0 < 10; b1 = 0.5; b2 = 1; b3 = 1.5
X < c(rep(c(0), n/2), rep(c(1), n/2))
set.seed(90)
Z < rnorm(n, 16, 5)
y < b0 + b1*X + b2*Z + b3*X*Z + rnorm(n, 0, sd = 10)
DATA3 = data.frame(cbind(y, X, Z))
# fit linear model with interaction
fit5.lm < lm(y ~ X*Z, data = DATA3)
# constraint syntax
myConstraints5 < ' AVE := X + 16.86137*X.Z;
AVE > 0 '
conTest(fit5.lm, constraints = myConstraints5)
# or
fit5.con < restriktor(fit5.lm, constraints = ' AVE := X + 16.86137*X.Z;
AVE > 0 ')
conTest(fit5.con)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.