Function orlm calculates order-restricted linear models (linear equality and inequality constraints). It uses the internal function boot.orlm for bootstrapping, which in turn uses the internal functions orlm_forboot... . The remaining functions extract coefficients, provide a residual plot, give a short printout or a more extensive summary.
orlm(model, ui, ci, ...)
# S3 method for lm
orlm(model, ui, ci, index = 2:length(coef(model)), meq = 0,
orig.out = FALSE, boot = FALSE, B = 1000, fixed = FALSE,
tol = sqrt(.Machine$double.eps), ...)
# S3 method for default
orlm(model, ui, ci, index = NULL, meq = 0,
tol = sqrt(.Machine$double.eps), df.error = NULL, ...)
boot.orlm(model, B = 1000, fixed = FALSE, ui, ci, index, meq)
orlm_forboot.fixed(data, indices, ...)
orlm_forboot(data, indices, index = index, ...)
# S3 method for orlm
coef(object, ...)
# S3 method for orlm
plot(x, caption = "Residuals vs Fitted",
panel = if (add.smooth) panel.smooth else points, sub.caption = NULL,
main = "", ..., id.n = 3, labels.id = names(x$residuals), cex.id = 0.75,
add.smooth = getOption("add.smooth"), label.pos = c(4, 2),
cex.caption = 1)
# S3 method for orlm
print(x, digits = max(3, getOption("digits") - 3), ...)
# S3 method for orlm
summary(object, display.unrestr = FALSE, brief = FALSE,
digits = max(3, getOption("digits") - 3),
scientific = FALSE, overall.tests = TRUE,
bootCIs = TRUE, bty = "perc", level = 0.95, ...)
The output of function orlm
belongs to S3 classes orlm
and orest
.
It is a list with the following items:
restricted estimate
unrestricted estimate
R-squared
residuals of restricted model
fitted values of restricted model
observation weights
R-squared of unrestricted model
error degrees of freedom of unrestricted model
MSE of unrestricted model
variance covariance matrix of beta-hat in unrestricted model
unrestricted model itself (NULL
,
if orig.out=FALSE
)
as input
as input
the input vector index
as input
active restrictions, i.e. restrictions that are satisfied with
equality in the solution, as output by solve.QP
object of class boot obtained by bootstrapping,
will be used by summary.orlm for calculating bootstrap confidence
intervals; NULL
if boot=FALSE
a linear model object (class lm
) with data included
OR
a covariance matrix of Y and all regressors (in this order)
matrix (or vector in case of one single restriction only) defining the left-hand side of the restriction
ui%*%beta >= ci
,
where beta is the parameter vector;
the first few of these restrictions can be declared equality- instead
of inequality restrictions (cf. argument meq
);
if only part of the elements of beta are subject to restrictions,
the columns of ui
can be restricted to these elements, if their
index numbers are provided in index
; by default, index
excludes the intercept, i.e. the columns of ui
refer to the
non-intercept elements of coef(model)
Rows of ui
must be linearly independent;
in case of linearly dependent rows the function gives an error
message with a hint which subset of rows is independent.
Note that the restrictions must define a (possibly translated) cone,
i.e. e.g. interval restrictions on a parameter are not permitted.
See contr.diff
for examples of how to comfortably
define various types of restriction.
vector on the right-hand side of the restriction (cf. ui
)
index numbers of the components of beta,
which are subject to the specified constraints
as ui%*%beta[index] >= ci
,
default is index = 2:length(coef(model))
,
i.e. ui
is supposed to have columns for all coefficients
except the intercept;
CAUTIONs:
- index
refers to the position of the coefficient in the model.
The first coefficient is usually the intercept (which is therefore
per default excluded from restrictions).
- If the intercept is included into restrictions (model with intercept,
index containing the element 1
, intercept-related column of ui
not consisting of zeroes only), R-squared values may become unreasonable,
if the restriction on the intercept is active.
integer number (default 0) giving the number of rows of ui
that
are used for equality restrictions instead of inequality
restrictions.
should the original model be included in the output list ?
(default: FALSE
)
should bootstrapping be conducted ? (default: FALSE
)
number of bootstrap samples (default: 1000
)
should bootstrapping consider the sample as fixed and bootstrap
residuals ? (default: FALSE
)
data handed to bootstrap sampling routine
indices for sampling
numerical tolerance value;
estimates closer to 0 than tol
are set to exactly 0
error degrees of freedom (number of observations minus
number of colummns of covariance matrix) for orlm.default
;
required in order to calculate adequate covariance matrix and tests;
valid coefficient estimates can also be obtained for arbitrary
values of df.error
Further options
object of class orlm
(created by function orlm
)
object of class orlm
(created by function orlm
)
like in function plot.lm
like in function plot.lm
like in function plot.lm
like in function plot.lm
like in function plot.lm
like in function plot.lm
like in function plot.lm
like in function plot.lm
like in function plot.lm
like in function plot.lm
number of digits to display
if TRUE
, also display unrestricted model;
default: FALSE
if TRUE
, suppress printing of restrictions;
default: FALSE
if FALSE
, suppresses scientific format;
default: FALSE
if FALSE
, suppresses output of overall model tests;
default: TRUE
; for models with large sets of restrictions,
tests can take up substantial time because of weight calculation
if FALSE
, suppresses bootstrap confidence intervals, even
though the obj
contains a bootout
element;
default: TRUE
type of bootstrap confidence interval; any of
"perc"
, "bca"
, "norm"
or "basic"
,
cf. function boot.ci
from package boot
,
default: "perc"
confidence level for bootstrap confidence intervals,
default: 0.95
Ulrike Groemping, BHT Berlin
Function orlm
performs order restricted linear model analysis.
Functions coef.orlm
, plot.orlm
, print.orlm
, and
summary.orlm
provide methods for reporting the results on an object
of S3 class orlm. The functions directly referring to bootstrapping are internal
and should not be called by the user but are called from within function orlm
if option boot
is set to TRUE
.
Of course, bootstrapping is not possible, if function orlm
is applied
to a covariance matrix, since the raw data are not available in this case. Also
note that the intercept is not estimated in this case but can easily be estimated
from the resulting estimate if the variable means are known (cf. example).
The output from summary.orlm provides information about the restrictions, a comparison of $R^2$-values for unrestricted and restricted model, restricted estimates, and
- if requested (option boot
set to TRUE
in function orlm
and
option bootCIs
set to TRUE
in the summary function)
with bootstrap confidence intervals,
- if requested (option overall.tests
set to TRUE
)
several restriction-related tests (implemented by calls to ic.test
):
The analogue to the overall F-Test in the ordinary linear model is the test of
all coefficients but intercept equal to 0 within the restricted parameter
space. In addition, three tests related to the restriction are reported:
Test 1: H0: Restriction valid with equality vs. H1: at least one inequality
Test 2: H0: Restriction valid vs. H1: restriction violated
Test 3: H0: Restriction violated or valid with equality vs. H1: all restrictions valid with inequality
Test 3 is conducted in case of no equality-restrictions only.
Shapiro, A. (1988) Towards a unified theory of inequality-constrained testing in multivariate analysis. International Statistical Review 56, 49--62
See also ic.est
, ic.test
,
or.relimp
, solve.QP
limo <- lm(swiss)
## restricted linear model with restrictions that
## - Education and Examination have same coefficient
## - Catholic and Infant.Mortality have non-negative coefficients
orlimo <- orlm(limo, ui=rbind(c(0,1,-1,0,0),c(0,0,0,1,0),c(0,0,0,0,1)), meq=1)
orlimo
plot(orlimo)
summary(orlimo)
## same model using index vector
orlimo <- orlm(limo, ui=rbind(c(1,-1,0,0),c(0,0,1,0),c(0,0,0,1)), index=3:6, meq=1)
## reduced number of bootstrap samples below reasonable size for example run time
orlimo <- orlm(limo, ui=rbind(c(1,-1,0,0),c(0,0,1,0),c(0,0,0,1)),
index=3:6, meq=1, boot=TRUE, B=100)
summary(orlimo)
## bootstrap considering data as fixed
orlimof <- orlm(limo, ui=rbind(c(1,-1,0,0),c(0,0,1,0),c(0,0,0,1)),
index=3:6, meq=1, boot=TRUE, B=100, fixed=TRUE)
summary(orlimof, brief=TRUE)
Run the code above in your browser using DataLab