Title: | Generalized Order-Restricted Information Criterion |
---|---|
Description: | Generalized Order-Restricted Information Criterion (GORIC) value for a set of hypotheses in multivariate linear models and generalised linear models. |
Authors: | Daniel Gerhard [aut, cre], Rebecca M. Kuiper [aut] |
Maintainer: | Daniel Gerhard <[email protected]> |
License: | GPL (>=2) |
Version: | 1.1-2 |
Built: | 2025-01-25 03:18:36 UTC |
Source: | https://github.com/daniel-gerhard/goric |
Generate a constraint matrix with a predefined structure
constrMat(n, type = c("monotone", "control", "average", "laverage", "uaverage", "caverage"), base = 1)
constrMat(n, type = c("monotone", "control", "average", "laverage", "uaverage", "caverage"), base = 1)
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") |
a constraint matrix
n <- c(10,20,30,40) constrMat(n, type="monotone") constrMat(n, type="control", base=2) constrMat(n, type="average") constrMat(n, type="laverage") constrMat(n, type="uaverage") constrMat(n, type="caverage", base=2)
n <- c(10,20,30,40) constrMat(n, type="monotone") constrMat(n, type="control", base=2) constrMat(n, type="average") constrMat(n, type="laverage") constrMat(n, type="uaverage") constrMat(n, type="caverage", base=2)
Generate sets of constraint matrices (constr), right hand side elements, and numbers of equality constraints (nec) with a predefined structure
constrSet(n, set = c("sequence", "seqcontrol", "lplateau", "uplateau", "downturn", "williams"), direction = c("increase", "decrease"), base = 1)
constrSet(n, set = c("sequence", "seqcontrol", "lplateau", "uplateau", "downturn", "williams"), direction = c("increase", "decrease"), base = 1)
n |
a (possibly named) vector of sample sizes for each group. |
set |
character string defining the type of constraints; one of "sequence", "seqcontrol", "lplateau", "uplateau", or "downturn" |
direction |
direction of the inequality constraints, either "increase" or "decrease" |
base |
column of the constraint matrix representing a control group |
a list with slots constr, rhs, and nec for each constraint definition
n <- c(10,20,30,40) constrSet(n, set="sequence") constrSet(n, set="seqcontrol") constrSet(n, set="lplateau") constrSet(n, set="uplateau") constrSet(n, set="downturn") constrSet(n, set="williams")
n <- c(10,20,30,40) constrSet(n, set="sequence") constrSet(n, set="seqcontrol") constrSet(n, set="lplateau") constrSet(n, set="uplateau") constrSet(n, set="downturn") constrSet(n, set="williams")
The goric function calculates the order-restricted log likelihood, the penalty of the generalised order restricted information criterion (GORIC), the GORIC values, differences to the minimum GORIC value, and the GORIC weights for a set of hypotheses, where the penalty is based on iterations.
The hypothesis with the lowest GORIC value is the preferred one.
The GORIC weights reflect the support of each hypothesis in the set. To compare two hypotheses (and not one to the whole set), one should examine the ratio of the two corresponding GORIC weights.
To safequard for weak hypotheses (i.e., hypotheses not supported by the data), one should include a model with no constraints (the so-called unconstrained model).
goric(object, ..., iter = 1e+05, type = "GORIC", dispersion = 1, mc.cores = 1) ## S3 method for class 'orlm' goric(object, ..., iter = 1e+05, type = "GORIC", mc.cores = 1) ## S3 method for class 'orgls' goric(object, ..., iter = 1e+05, type = "GORIC", mc.cores = 1) ## S3 method for class 'list' goric(object, ..., iter = 1e+05, type = "GORIC", dispersion = 1, mc.cores = 1) ## S3 method for class 'orglm' goric(object, ..., iter = 1e+05, type = "GORIC", dispersion = 1, mc.cores = 1)
goric(object, ..., iter = 1e+05, type = "GORIC", dispersion = 1, mc.cores = 1) ## S3 method for class 'orlm' goric(object, ..., iter = 1e+05, type = "GORIC", mc.cores = 1) ## S3 method for class 'orgls' goric(object, ..., iter = 1e+05, type = "GORIC", mc.cores = 1) ## S3 method for class 'list' goric(object, ..., iter = 1e+05, type = "GORIC", dispersion = 1, mc.cores = 1) ## S3 method for class 'orglm' goric(object, ..., iter = 1e+05, type = "GORIC", dispersion = 1, mc.cores = 1)
object |
an object of class orlm, orgls, orglm, or a list of these objects |
... |
further objects of class orlm, orgls, or orglm |
iter |
number of iterations to calculate GORIC penalty terms |
type |
if |
dispersion |
dispersion parameter to scale GORIC analogously to QAIC in generalized linear models |
mc.cores |
number of cores using a socket cluster implemented in package |
a data.frame with the information criteria or a single penalty term
Kuiper R.M., Hoijtink H., Silvapulle M.J. (2011). An Akaike-type Information Criterion for Model Selection Under Inequality Constraints. Biometrika, 98, 495–501.
Kuiper R.M., Hoijtink H., Silvapulle M.J. (2012). Generalization of the Order-Restricted Information Criterion for Multivariate Normal Linear Models. Journal of Statistical Planning and Inference, 142, 2454-2463. doi:10.1016/j.jspi.2012.03.007.
Kuiper R.M. and Hoijtink H. (submitted). A Fortran 90 Program for the Generalization of the Order-Restricted Information Criterion. Journal of Statictical Software.
## Example from Kuiper, R.M. and Hoijtink, H. (Unpublished). # A Fortran 90 program for the generalization of the # order restricted information criterion. # constraint definition cmat <- cbind(diag(3), 0) + cbind(0, -diag(3)) constr <- kronecker(diag(3), cmat) constr # no effect model (fm0 <- orlm(cbind(SDH, SGOT, SGPT) ~ dose-1, data=vinylidene, constr=constr, rhs=rep(0, nrow(constr)), nec=nrow(constr))) # order constrained model (increasing serum levels with increasing doses) fm1 <- orlm(cbind(SDH, SGOT, SGPT) ~ dose-1, data=vinylidene, constr=constr, rhs=rep(0, nrow(constr)), nec=0) summary(fm1) # unconstrained model (fmunc <- orlm(cbind(SDH, SGOT, SGPT) ~ dose-1, data=vinylidene, constr=matrix(0, nrow=1, ncol=12), rhs=0, nec=0)) # calculate GORIC # (only small number of iterations to decrease computation time, default: iter=100000) goric(fm0, fm1, fmunc, iter=1000)
## Example from Kuiper, R.M. and Hoijtink, H. (Unpublished). # A Fortran 90 program for the generalization of the # order restricted information criterion. # constraint definition cmat <- cbind(diag(3), 0) + cbind(0, -diag(3)) constr <- kronecker(diag(3), cmat) constr # no effect model (fm0 <- orlm(cbind(SDH, SGOT, SGPT) ~ dose-1, data=vinylidene, constr=constr, rhs=rep(0, nrow(constr)), nec=nrow(constr))) # order constrained model (increasing serum levels with increasing doses) fm1 <- orlm(cbind(SDH, SGOT, SGPT) ~ dose-1, data=vinylidene, constr=constr, rhs=rep(0, nrow(constr)), nec=0) summary(fm1) # unconstrained model (fmunc <- orlm(cbind(SDH, SGOT, SGPT) ~ dose-1, data=vinylidene, constr=matrix(0, nrow=1, ncol=12), rhs=0, nec=0)) # calculate GORIC # (only small number of iterations to decrease computation time, default: iter=100000) goric(fm0, fm1, fmunc, iter=1000)
Calculates the GORIC penalty term (level probability) by Monte-Carlo simulation.
goric_penalty(object, iter = 1e+05, type = "GORIC", mc.cores = 1) orglm_penalty(object, iter = 1e+05, type = "GORIC", mc.cores = 1)
goric_penalty(object, iter = 1e+05, type = "GORIC", mc.cores = 1) orglm_penalty(object, iter = 1e+05, type = "GORIC", mc.cores = 1)
object |
an object of class orlm, orgls (or orglm for function |
iter |
number of iterations to calculate GORIC penalty terms |
type |
if |
mc.cores |
number of cores using a socket cluster implemented in package |
orglm
is used to fit generalised linear models with restrictions on the parameters, specified by giving a description of the linear predictor, a description of the error distribution, and a description of a matrix with linear constraints. The quadprog
package is used to apply linear constraints on the parameter vector.
orglm(formula, family = gaussian, data, weights, subset, na.action, start = NULL, etastart, mustart, offset, control = list(...), model = TRUE, method = "orglm.fit", x = FALSE, y = TRUE, contrasts = NULL, constr, rhs, nec, ...) orglm.fit(x, y, weights = rep(1, nobs), start = NULL, etastart = NULL, mustart = NULL, offset = rep(0, nobs), family = gaussian(), control = list(), intercept = TRUE, constr, rhs, nec)
orglm(formula, family = gaussian, data, weights, subset, na.action, start = NULL, etastart, mustart, offset, control = list(...), model = TRUE, method = "orglm.fit", x = FALSE, y = TRUE, contrasts = NULL, constr, rhs, nec, ...) orglm.fit(x, y, weights = rep(1, nobs), start = NULL, etastart = NULL, mustart = NULL, offset = rep(0, nobs), family = gaussian(), control = list(), intercept = TRUE, constr, rhs, nec)
formula |
an object of class |
family |
a description of the error distribution and link function to be used in the model. This can be a character string naming a family function, a family function or the result of a call to a family function. (See |
data |
an optional data frame, list or environment (or object coercible by |
weights |
an optional vector of ‘prior weights’ to be used in the fitting process. Should be |
subset |
an optional vector specifying a subset of observations to be used in the fitting process. |
na.action |
a function which indicates what should happen when the data contain |
start |
starting values for the parameters in the linear predictor. |
etastart |
starting values for the linear predictor. |
mustart |
starting values for the vector of means. |
offset |
this can be used to specify an a priori known component to be included in the linear predictor during fitting. This should be |
control |
a list of parameters for controlling the fitting process. For |
model |
a logical value indicating whether model frame should be included as a component of the returned value. |
method |
the method to be used in fitting the model. The default method |
x |
is a design matrix of dimension |
y |
is a vector of observations of length |
contrasts |
an optional list. See the |
constr |
a matrix with linear constraints. The columns of this matrix should correspond to the columns of the design matrix. |
rhs |
right hand side of the linear constraint formulation. A numeric vector with a length corresponding to the rows of |
nec |
Number of equality constrints. The first |
... |
For |
intercept |
logical. Should an intercept be included in the null model? |
Non-NULL
weights
can be used to indicate that different observations have different dispersions (with the values in weights
being inversely proportional to the dispersions); or equivalently, when the elements of weights
are positive integers , that each response
is the mean of
unit-weight observations. For a binomial GLM prior weights are used to give the number of trials when the response is the proportion of successes: they would rarely be used for a Poisson GLM.
If more than one of
etastart
, start
and mustart
is specified, the first in the list will be used. It is often advisable to supply starting values for a quasi
family, and also for families with unusual links such as gaussian("log")
.
For the background to warning messages about ‘fitted probabilities numerically 0 or 1 occurred’ for binomial GLMs, see Venables & Ripley (2002, pp. 197–8).
An object of class "orglm"
is a list containing at least the following components:
a named vector of coefficients
the working residuals, that is the residuals in the final iteration of the IWLS fit. Since cases with zero weights are omitted, their working residuals are NA
.
the fitted mean values, obtained by transforming the linear predictors by the inverse of the link function.
the numeric rank of the fitted linear model.
the family
object used.
the linear fit on link scale.
up to a constant, minus twice the maximized log-likelihood. Where sensible, the constant is chosen so that a saturated model has deviance zero.
The deviance for the null model, comparable with deviance
. The null model will include the offset, and an intercept if there is one in the model. Note that this will be incorrect if the link function depends on the data other than through the fitted mean: specify a zero offset to force a correct calculation.
the number of iterations of IWLS used.
the working weights, that is the weights in the final iteration of the IWLS fit.
the weights initially supplied, a vector of 1
s if none were.
the residual degrees of freedom of the unconstrained model.
the residual degrees of freedom for the null model.
if requested (the default) the y
vector used. (It is a vector even for a binomial model.)
logical. Was the IWLS algorithm judged to have converged?
logical. Is the fitted value on the boundary of the attainable values?
Modification of the original glm.fit by Daniel Gerhard.
The original R implementation of glm
was written by Simon Davies working for Ross Ihaka at the University of Auckland, but has since been extensively re-written by members of the R Core team.
The design was inspired by the S function of the same name described in Hastie & Pregibon (1992).
Dobson, A. J. (1990) An Introduction to Generalized Linear Models. London: Chapman and Hall.
Hastie, T. J. and Pregibon, D. (1992) Generalized linear models. Chapter 6 of Statistical Models in S eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks//Cole.
McCullagh P. and Nelder, J. A. (1989) Generalized Linear Models. London: Chapman and Hall.
Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. New York: Springer.
orgls
is used to fit generalised least square models analogously to the function gls
in package nlme
but with order restrictions on the parameters.
orgls(formula, data, constr, rhs, nec, weights = NULL, correlation = NULL, control = orlmcontrol()) ## S3 method for class 'formula' orgls(formula, data, constr, rhs, nec, weights = NULL, correlation = NULL, control = orlmcontrol())
orgls(formula, data, constr, rhs, nec, weights = NULL, correlation = NULL, control = orlmcontrol()) ## S3 method for class 'formula' orgls(formula, data, constr, rhs, nec, weights = NULL, correlation = NULL, control = orlmcontrol())
formula |
an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted. |
data |
an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which orgls is called. |
constr |
matrix with constraints; with rows as constraint definition, columns should be in line with the parameters of the model |
rhs |
vector of right hand side elements; |
nec |
number of equality constraints; a numeric value treating the first nec constr rows as equality constraints, or a logical vector with |
weights |
a |
correlation |
a |
control |
a list of control arguments; see |
The contraints in the hypothesis of interest are defined by ,
, and
. The first
constraints are the equality contraints:
; and the remaing ones are the inequality contraints:
.
Two requirements should be met:
The first constraints must be the equality contraints (i.e.,
) and the remaining ones the inequality contraints (i.e.,
).
When is not zero,
should be of full rank (after discarding redundant restrictions).
an object of class orgls
Kuiper R.M., Hoijtink H., Silvapulle M.J. (2011). An Akaike-type Information Criterion for Model Selection Under Inequality Constraints. Biometrika, 98, 495–501.
Kuiper R.M., Hoijtink H., Silvapulle M.J. (2012). Generalization of the Order-Restricted Information Criterion for Multivariate Normal Linear Models. Journal of Statistical Planning and Inference, 142, 2454-2463. doi:10.1016//j.jspi.2012.03.007.
Kuiper R.M. and Hoijtink H. (submitted). A Fortran 90 Program for the Generalization of the Order-Restricted Information Criterion. Journal of Statictical Software.
# generating example data library(mvtnorm) # group means m <- c(0,5,5,7) # compound symmetry structure of residuals # (10 individuals per group, rho=0.7) cormat <- kronecker(diag(length(m)*10), matrix(0.7, nrow=length(m), ncol=length(m))) diag(cormat) <- 1 # different variances per group sds <- rep(c(1,2,0.5,1), times=10*length(m)) sigma <- crossprod(diag(sds), crossprod(cormat, diag(sds))) response <- as.vector(rmvnorm(1, rep(m, times=10*length(m)), sigma=sigma)) dat <- data.frame(response, grp=rep(LETTERS[1:length(m)], times=10*length(m)), ID=as.factor(rep(1:(10*length(m)), each=length(m)))) ## set of gls models: # unconstrained model m1 <- orgls(response ~ grp-1, data = dat, constr=rbind(c(0,0,0,0)), rhs=0, nec=0, weights=varIdent(form=~1|grp), correlation=corCompSymm(form=~1|ID)) # simple order m2 <- orgls(response ~ grp-1, data = dat, constr=rbind(c(-1,1,0,0),c(0,-1,1,0),c(0,0,-1,1)), rhs=c(0,0,0), nec=0, weights=varIdent(form=~1|grp), correlation=corCompSymm(form=~1|ID)) # equality constraints m3 <- orgls(response ~ grp-1, data = dat, constr=rbind(c(-1,1,0,0),c(0,-1,1,0),c(0,0,-1,1)), rhs=c(0,0,0), nec=3, weights=varIdent(form=~1|grp), correlation=corCompSymm(form=~1|ID))
# generating example data library(mvtnorm) # group means m <- c(0,5,5,7) # compound symmetry structure of residuals # (10 individuals per group, rho=0.7) cormat <- kronecker(diag(length(m)*10), matrix(0.7, nrow=length(m), ncol=length(m))) diag(cormat) <- 1 # different variances per group sds <- rep(c(1,2,0.5,1), times=10*length(m)) sigma <- crossprod(diag(sds), crossprod(cormat, diag(sds))) response <- as.vector(rmvnorm(1, rep(m, times=10*length(m)), sigma=sigma)) dat <- data.frame(response, grp=rep(LETTERS[1:length(m)], times=10*length(m)), ID=as.factor(rep(1:(10*length(m)), each=length(m)))) ## set of gls models: # unconstrained model m1 <- orgls(response ~ grp-1, data = dat, constr=rbind(c(0,0,0,0)), rhs=0, nec=0, weights=varIdent(form=~1|grp), correlation=corCompSymm(form=~1|ID)) # simple order m2 <- orgls(response ~ grp-1, data = dat, constr=rbind(c(-1,1,0,0),c(0,-1,1,0),c(0,0,-1,1)), rhs=c(0,0,0), nec=0, weights=varIdent(form=~1|grp), correlation=corCompSymm(form=~1|ID)) # equality constraints m3 <- orgls(response ~ grp-1, data = dat, constr=rbind(c(-1,1,0,0),c(0,-1,1,0),c(0,0,-1,1)), rhs=c(0,0,0), nec=3, weights=varIdent(form=~1|grp), correlation=corCompSymm(form=~1|ID))
Fitting a specific set of generalisd least-squares models with order restrictions.
orglsSet(formula, data, weights = NULL, correlation = NULL, set, direction = "increase", n = NULL, base = 1, control = orlmcontrol())
orglsSet(formula, data, weights = NULL, correlation = NULL, set, direction = "increase", n = NULL, base = 1, control = orlmcontrol())
formula |
an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted. |
data |
an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which lm is called. |
weights |
a |
correlation |
a |
set |
either a character string (see |
direction |
direction of the order constraints |
n |
a (possibly named) vector of sample sizes for each group |
base |
column of the constraint matrix representing a control group |
control |
a list of control arguments; see |
This function is just a wrapper for repeated calls of orgls
with different constraint definitions. Predefined lists with constraint-sets can be constructed with function constrSet
.
a list with orgls objects
This is a modification of the lm
function, fitting (multivariate) linear models with order constraints on the model coefficients.
orlm(formula, data, constr, rhs, nec, control = orlmcontrol()) ## S3 method for class 'formula' orlm(formula, data, constr, rhs, nec, control = orlmcontrol())
orlm(formula, data, constr, rhs, nec, control = orlmcontrol()) ## S3 method for class 'formula' orlm(formula, data, constr, rhs, nec, control = orlmcontrol())
formula |
an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted. |
data |
an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which lm is called. |
constr |
matrix with constraints; with rows as constraint definition, columns should be in line with the parameters of the model |
rhs |
vector of right hand side elements; |
nec |
number of equality constraints; a numeric value treating the first nec constr rows as equality constraints, or a logical vector with |
control |
a list of control arguments; see |
The contraints in the hypothesis of interest are defined by ,
, and
. The first
constraints are the equality contraints:
; and the remaing ones are the inequality contraints:
.
Two requirements should be met:
The first constraints must be the equality contraints (i.e.,
) and the remaining ones the inequality contraints (i.e.,
).
When is not zero,
should be of full rank (after discarding redundant restrictions).
an object of class orlm
Kuiper R.M., Hoijtink H., Silvapulle M.J. (2011). An Akaike-type Information Criterion for Model Selection Under Inequality Constraints. Biometrika, 98, 495–501.
Kuiper R.M., Hoijtink H., Silvapulle M.J. (2012). Generalization of the Order-Restricted Information Criterion for Multivariate Normal Linear Models. Journal of Statistical Planning and Inference, 142, 2454-2463. doi:10.1016//j.jspi.2012.03.007.
Kuiper R.M. and Hoijtink H. (submitted). A Fortran 90 Program for the Generalization of the Order-Restricted Information Criterion. Journal of Statictical Software.
######################## ## Artificial example ## ######################## n <- 10 m <- c(1,2,1,5) nm <- length(m) dat <- data.frame(grp=as.factor(rep(1:nm, each=n)), y=rnorm(n*nm, rep(m, each=n), 1)) # unrestricted linear model cm1 <- matrix(0, nrow=1, ncol=4) fm1 <- orlm(y ~ grp-1, data=dat, constr=cm1, rhs=0, nec=0) # order restriction (increasing means) cm2 <- rbind(c(-1,1,0,0), c(0,-1,1,0), c(0,0,-1,1)) fm2 <- orlm(y ~ grp-1, data=dat, constr=cm2, rhs=rep(0,nrow(cm2)), nec=0) # order restriction (increasing at least by delta=1) fm3 <- orlm(y ~ grp-1, data=dat, constr=cm2, rhs=rep(1,nrow(cm2)), nec=0) # larger than average of the neighboring first 2 parameters cm4 <- rbind(c(-0.5,-0.5,1,0), c(0,-0.5,-0.5,1)) fm4 <- orlm(y ~ grp-1, data=dat, constr=cm4, rhs=rep(0,nrow(cm4)), nec=0) # equality constraints (all parameters equal) fm5 <- orlm(y ~ grp-1, data=dat, constr=cm2, rhs=rep(0,nrow(cm2)), nec=nrow(cm2)) # alternatively fm5 <- orlm(y ~ grp-1, data=dat, constr=cm2, rhs=rep(0,nrow(cm2)), nec=c(TRUE,TRUE,TRUE)) # constraining the 1st and the 4th parameter # to their true values, and the 2nd and 3rd between them cm6 <- rbind(c( 1,0,0,0), c(-1,1,0,0), c(0,-1,0,1), c(-1,0,1,0), c(0,0,-1,1), c(0,0, 0,1)) fm6 <- orlm(y ~ grp-1, data=dat, constr=cm6, rhs=c(1,rep(0,4),5), nec=c(TRUE,rep(FALSE,4),TRUE)) ############################################################### ## Example from Kuiper, R.M. and Hoijtink, H. (Unpublished). ## ## A Fortran 90 program for the generalization of the ## ## order restricted information criterion. ## ############################################################### # constraint definition cmat <- cbind(diag(3), 0) + cbind(0, -diag(3)) constr <- kronecker(diag(3), cmat) # no effect model (fm0 <- orlm(cbind(SDH, SGOT, SGPT) ~ dose-1, data=vinylidene, constr=constr, rhs=rep(0, nrow(constr)), nec=nrow(constr))) # order constrained model (increasing serum levels with increasing doses) fm1 <- orlm(cbind(SDH, SGOT, SGPT) ~ dose-1, data=vinylidene, constr=constr, rhs=rep(0, nrow(constr)), nec=0) summary(fm1) # unconstrained model (fmunc <- orlm(cbind(SDH, SGOT, SGPT) ~ dose-1, data=vinylidene, constr=matrix(0, nrow=1, ncol=12), rhs=0, nec=0))
######################## ## Artificial example ## ######################## n <- 10 m <- c(1,2,1,5) nm <- length(m) dat <- data.frame(grp=as.factor(rep(1:nm, each=n)), y=rnorm(n*nm, rep(m, each=n), 1)) # unrestricted linear model cm1 <- matrix(0, nrow=1, ncol=4) fm1 <- orlm(y ~ grp-1, data=dat, constr=cm1, rhs=0, nec=0) # order restriction (increasing means) cm2 <- rbind(c(-1,1,0,0), c(0,-1,1,0), c(0,0,-1,1)) fm2 <- orlm(y ~ grp-1, data=dat, constr=cm2, rhs=rep(0,nrow(cm2)), nec=0) # order restriction (increasing at least by delta=1) fm3 <- orlm(y ~ grp-1, data=dat, constr=cm2, rhs=rep(1,nrow(cm2)), nec=0) # larger than average of the neighboring first 2 parameters cm4 <- rbind(c(-0.5,-0.5,1,0), c(0,-0.5,-0.5,1)) fm4 <- orlm(y ~ grp-1, data=dat, constr=cm4, rhs=rep(0,nrow(cm4)), nec=0) # equality constraints (all parameters equal) fm5 <- orlm(y ~ grp-1, data=dat, constr=cm2, rhs=rep(0,nrow(cm2)), nec=nrow(cm2)) # alternatively fm5 <- orlm(y ~ grp-1, data=dat, constr=cm2, rhs=rep(0,nrow(cm2)), nec=c(TRUE,TRUE,TRUE)) # constraining the 1st and the 4th parameter # to their true values, and the 2nd and 3rd between them cm6 <- rbind(c( 1,0,0,0), c(-1,1,0,0), c(0,-1,0,1), c(-1,0,1,0), c(0,0,-1,1), c(0,0, 0,1)) fm6 <- orlm(y ~ grp-1, data=dat, constr=cm6, rhs=c(1,rep(0,4),5), nec=c(TRUE,rep(FALSE,4),TRUE)) ############################################################### ## Example from Kuiper, R.M. and Hoijtink, H. (Unpublished). ## ## A Fortran 90 program for the generalization of the ## ## order restricted information criterion. ## ############################################################### # constraint definition cmat <- cbind(diag(3), 0) + cbind(0, -diag(3)) constr <- kronecker(diag(3), cmat) # no effect model (fm0 <- orlm(cbind(SDH, SGOT, SGPT) ~ dose-1, data=vinylidene, constr=constr, rhs=rep(0, nrow(constr)), nec=nrow(constr))) # order constrained model (increasing serum levels with increasing doses) fm1 <- orlm(cbind(SDH, SGOT, SGPT) ~ dose-1, data=vinylidene, constr=constr, rhs=rep(0, nrow(constr)), nec=0) summary(fm1) # unconstrained model (fmunc <- orlm(cbind(SDH, SGOT, SGPT) ~ dose-1, data=vinylidene, constr=matrix(0, nrow=1, ncol=12), rhs=0, nec=0))
A list with control arguments controlling the orlm function
orlmcontrol(maxiter = 10000, absval = 1e-04)
orlmcontrol(maxiter = 10000, absval = 1e-04)
maxiter |
maximum number of iterations |
absval |
tolerance criterion for convergence |
a list with control arguments
Fitting a specific set of multivariate regression models with order restrictions.
orlmSet(formula, data, set, direction = "increase", n = NULL, base = 1, control = orlmcontrol())
orlmSet(formula, data, set, direction = "increase", n = NULL, base = 1, control = orlmcontrol())
formula |
an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted. |
data |
an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which lm is called. |
set |
either a character string (see |
direction |
direction of the order constraints |
n |
a (possibly named) vector of sample sizes for each group |
base |
column of the constraint matrix representing a control group |
control |
a list of control arguments; see |
This function is just a wrapper for repeated calls of orlm
with different constraint definitions. Predefined lists with constraint-sets can be constructed with function constrSet
.
a list with orlm objects
######################## ## Artificial example ## ######################## n <- 10 m <- c(1,2,4,5,2,1) nm <- length(m) dat <- data.frame(grp=as.factor(rep(1:nm, each=n)), y=rnorm(n*nm, rep(m, each=n), 1)) (cs <- constrSet(table(dat$grp), set="sequence")) (oss <- orlmSet(y ~ grp-1, data=dat, set=cs)) # the same as: oss <- orlmSet(y ~ grp-1, data=dat, set="sequence")
######################## ## Artificial example ## ######################## n <- 10 m <- c(1,2,4,5,2,1) nm <- length(m) dat <- data.frame(grp=as.factor(rep(1:nm, each=n)), y=rnorm(n*nm, rep(m, each=n), 1)) (cs <- constrSet(table(dat$grp), set="sequence")) (oss <- orlmSet(y ~ grp-1, data=dat, set=cs)) # the same as: oss <- orlmSet(y ~ grp-1, data=dat, set="sequence")
Simulation function for orlm and orgls objects
sim(object, n.sims) ## S3 method for class 'orlm' sim(object, n.sims) ## S3 method for class 'orgls' sim(object, n.sims)
sim(object, n.sims) ## S3 method for class 'orlm' sim(object, n.sims) ## S3 method for class 'orgls' sim(object, n.sims)
object |
an object of class "orlm" or "orgls". |
n.sims |
number of simulation replications. |
Given the estimated coefficients of a orlm or orgls model, a set new parameters are generated. n.sims new sets of observations are generated based on the unrestricted model; these new datasets are used to estimate a new set of model coefficients incorporating the given order restrictions.
a list with sets of simulated parameters.
######################## ## Artificial example ## ######################## n <- 10 m <- c(1,1,2) dat <- data.frame(grp=as.factor(rep(1:length(m), each=n)), y=rnorm(n*length(m), rep(m, each=n), 1)) cm <- rbind(c(-1,1,0), c(0,-1,1)) fm <- orlm(y ~ grp-1, data=dat, constr=cm, rhs=rep(0,nrow(cm)), nec=0) b <- sim(fm, n.sims=1000)$coef pairs(t(b), cex=0.3)
######################## ## Artificial example ## ######################## n <- 10 m <- c(1,1,2) dat <- data.frame(grp=as.factor(rep(1:length(m), each=n)), y=rnorm(n*length(m), rep(m, each=n), 1)) cm <- rbind(c(-1,1,0), c(0,-1,1)) fm <- orlm(y ~ grp-1, data=dat, constr=cm, rhs=rep(0,nrow(cm)), nec=0) b <- sim(fm, n.sims=1000)$coef pairs(t(b), cex=0.3)
Real data which are available on page 10 of Silvapulle and Sen (2005) and in a report prepared by Litton Bionetics Inc in 1984. These data were used in an experiment to find out whether vinylidene fluoride gives rise to liver damage. Since increased levels of serum enzyme are inherent in liver damage, the focus is on whether enzyme levels are affected by vinylidene fluoride. The variable of interest is the serum enzyme level. Three types of enzymes are inspected, namely SDH, SGOT, and SGPT. To study whether vinylidene fluoride has an influence on the three serum enzymes, four dosages of this substance are examined. In each of these four treatment groups, ten male Fischer-344 rats received the substance.
vinylidene
vinylidene
A data frame with 40 observations on the following 4 variables.
SDH
serum enzyme level of enzyme type SDH.
SGOT
serum enzyme level of enzyme type SGOT.
SGPT
serum enzyme level of enzyme type SGPT.
dose
factor with 4 levels (d1-d4) representing the 4 vinylidene fluoride concentrations.
Silvapulle MJ, Sen PK (2005). Constrained Statistical Inference. New Jersey: Wiley.