Title: | Active Set and Generalized PAVA for Isotone Optimization |
---|---|
Description: | Contains two main functions: one for solving general isotone regression problems using the pool-adjacent-violators algorithm (PAVA); another one provides a framework for active set methods for isotone optimization problems with arbitrary order restrictions. Various types of loss functions are prespecified. |
Authors: | Patrick Mair [aut, cre], Jan De Leeuw [aut], Kurt Hornik [aut] |
Maintainer: | Patrick Mair <[email protected]> |
License: | GPL-2 |
Version: | 1.1-1 |
Built: | 2024-11-15 05:06:32 UTC |
Source: | https://github.com/r-forge/psychor |
Isotone optimization can be formulated as a convex programming problem with simple linear constraints. This functions offers active set strategies for a collection of isotone optimization problems pre-specified in the package.
activeSet(isomat, mySolver = "LS", x0 = NULL, ups = 1e-12, check = TRUE, maxiter = 100, ...)
activeSet(isomat, mySolver = "LS", x0 = NULL, ups = 1e-12, check = TRUE, maxiter = 100, ...)
isomat |
Matrix with 2 columns that contains isotonicity conditions, i.e. for row i it holds that fitted value i column 1 <= fitted value i column 2 (see examples) |
mySolver |
Various functions are pre-defined (see details). Either to funtction name or the corresponding string equivalent can be used. For user-specified functions |
x0 |
Feasible starting solution. If |
ups |
Upper boundary |
check |
If TRUE, KKT feasibility checks for isotonicity of the solution are performed |
maxiter |
Iteration limit |
... |
Additional arguments for the various solvers (see details) |
The following solvers are specified. Note that y
as the vector of observed values and weights
as the vector of weights need to provided through ...
for each solver (except for fSolver()
and sSolver()
). Some solvers need additional arguments as described in the corresponding solver help files. More technical details can be found in the package vignette.
The pre-specified solvers are the following (we always give the corresponding string equivalent in brackets):
lsSolver()
("LS"
) for least squares with diagonal weights, aSolver()
("asyLS"
) for asymmetric least squares, dSolver()
("L1"
) for the least absolute value, eSolver()
("L1eps"
) minimizes l1-approximation. hSolver()
("huber"
) for Huber loss function, iSolver()
("SILF"
) for SILF loss (support vector regression), lfSolver()
("GLS"
) for general least squares with non-diagonal weights, mSolver()
("chebyshev"
) for Chebyshev L-inf norm, oSolver()
("Lp"
) for L-p power norm, pSolver()
("quantile"
) for quantile loss function, and finally sSolver()
("poisson"
) for Poisson likelihood.
fSolver()
for user-specified arbitrary differentiable functions. The arguments fobj
(target function ) and gobj
(first derivative) must be provided plus any additional arguments used in the definition of fobj
.
Generates an object of class activeset
.
x |
Vector containing the fitted values |
y |
Vector containing the observed values |
lambda |
Vector with Lagrange multipliers |
fval |
Value of the target function |
constr.vals |
Vector with the values of isotonicity constraints |
Alambda |
Constraint matrix multiplied by lambda (should be equal to gradient) |
gradient |
Gradient |
isocheck |
List containing the KKT checks for stationarity, primal feasibility, dual feasibility, and complementary slackness (>= 0 means feasible) |
niter |
Number of iterations |
call |
Matched call |
Jan de Leeuw, Kurt Hornik, Patrick Mair
de Leeuw, J., Hornik, K., Mair, P. (2009). Isotone optimization in R: Active Set methods and pool-adjacent-violators algorithm. Journal of Statistical Software, 32(5), 1-24.
gpava
, lsSolver
, dSolver
, mSolver
, fSolver
,
pSolver
, lfSolver
, oSolver
, aSolver
, eSolver
,
sSolver
, hSolver
, iSolver
## Data specification set.seed(12345) y <- rnorm(9) ##normal distributed response values w1 <- rep(1,9) ##unit weights Atot <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) Atot ## Least squares solver (pre-specified and user-specified) fit.ls1 <- activeSet(Atot, "LS", y = y, weights = w1) fit.ls1 summary(fit.ls1) fit.ls2 <- activeSet(Atot, fSolver, fobj = function(x) sum(w1*(x-y)^2), gobj = function(x) 2*drop(w1*(x-y)), y = y, weights = w1) ## LS vs. GLS solver (needs weight matrix) set.seed(12345) wvec <- 1:9 wmat <- crossprod(matrix(rnorm(81),9,9))/9 fit.wls <- activeSet(Atot, "LS", y = y, weights = wvec) fit.gls <- activeSet(Atot, "GLS", y = y, weights = wmat) ## Quantile regression fit.qua <- activeSet(Atot, "quantile", y = y, weights = wvec, aw = 0.3, bw = 0.7) ## Mean absolute value norm fit.abs <- activeSet(Atot, "L1", y = y, weights = w1) ## Lp norm fit.pow <- activeSet(Atot, "Lp", y = y, weights = w1, p = 1.2) ## Chebyshev norm fit.che <- activeSet(Atot, "chebyshev", y = y, weights = w1) ## Efron's asymmetric LS fit.asy <- activeSet(Atot, "asyLS", y = y, weights = w1, aw = 2, bw = 1) ## Huber and SILF loss fit.hub <- activeSet(Atot, "huber", y = y, weights = w1, eps = 1) fit.svm <- activeSet(Atot, "SILF", y = y, weights = w1, beta = 0.8, eps = 0.2) ## Negative Poisson log-likelihood set.seed(12345) yp <- rpois(9,5) x0 <- 1:9 fit.poi <- activeSet(Atot, "poisson", x0 = x0, y = yp) ## LS on tree ordering Atree <- matrix(c(1,1,2,2,2,3,3,8,2,3,4,5,6,7,8,9),8,2) Atree fit.tree <- activeSet(Atree, "LS", y = y, weights = w1) ## LS on loop ordering Aloop <- matrix(c(1,2,3,3,4,5,6,6,7,8,3,3,4,5,6,6,7,8,9,9),10,2) Aloop fit.loop <- activeSet(Aloop, "LS", y = y, weights = w1) ## LS on block ordering Ablock <- cbind(c(rep(1,3),rep(2,3),rep(3,3),rep(4,3),rep(5,3),rep(6,3)),c(rep(c(4,5,6),3), rep(c(7,8,9),3))) Ablock fit.block <- activeSet(Ablock, "LS", y = y, weights = w1) ## Isotone LS regression using gpava and active set (same results) pava.fitted <- gpava(y = y)$x aset.fitted <- activeSet(Atot, "LS", weights = w1, y = y)$x mse <- mean((pava.fitted - aset.fitted)^2) mse
## Data specification set.seed(12345) y <- rnorm(9) ##normal distributed response values w1 <- rep(1,9) ##unit weights Atot <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) Atot ## Least squares solver (pre-specified and user-specified) fit.ls1 <- activeSet(Atot, "LS", y = y, weights = w1) fit.ls1 summary(fit.ls1) fit.ls2 <- activeSet(Atot, fSolver, fobj = function(x) sum(w1*(x-y)^2), gobj = function(x) 2*drop(w1*(x-y)), y = y, weights = w1) ## LS vs. GLS solver (needs weight matrix) set.seed(12345) wvec <- 1:9 wmat <- crossprod(matrix(rnorm(81),9,9))/9 fit.wls <- activeSet(Atot, "LS", y = y, weights = wvec) fit.gls <- activeSet(Atot, "GLS", y = y, weights = wmat) ## Quantile regression fit.qua <- activeSet(Atot, "quantile", y = y, weights = wvec, aw = 0.3, bw = 0.7) ## Mean absolute value norm fit.abs <- activeSet(Atot, "L1", y = y, weights = w1) ## Lp norm fit.pow <- activeSet(Atot, "Lp", y = y, weights = w1, p = 1.2) ## Chebyshev norm fit.che <- activeSet(Atot, "chebyshev", y = y, weights = w1) ## Efron's asymmetric LS fit.asy <- activeSet(Atot, "asyLS", y = y, weights = w1, aw = 2, bw = 1) ## Huber and SILF loss fit.hub <- activeSet(Atot, "huber", y = y, weights = w1, eps = 1) fit.svm <- activeSet(Atot, "SILF", y = y, weights = w1, beta = 0.8, eps = 0.2) ## Negative Poisson log-likelihood set.seed(12345) yp <- rpois(9,5) x0 <- 1:9 fit.poi <- activeSet(Atot, "poisson", x0 = x0, y = yp) ## LS on tree ordering Atree <- matrix(c(1,1,2,2,2,3,3,8,2,3,4,5,6,7,8,9),8,2) Atree fit.tree <- activeSet(Atree, "LS", y = y, weights = w1) ## LS on loop ordering Aloop <- matrix(c(1,2,3,3,4,5,6,6,7,8,3,3,4,5,6,6,7,8,9,9),10,2) Aloop fit.loop <- activeSet(Aloop, "LS", y = y, weights = w1) ## LS on block ordering Ablock <- cbind(c(rep(1,3),rep(2,3),rep(3,3),rep(4,3),rep(5,3),rep(6,3)),c(rep(c(4,5,6),3), rep(c(7,8,9),3))) Ablock fit.block <- activeSet(Ablock, "LS", y = y, weights = w1) ## Isotone LS regression using gpava and active set (same results) pava.fitted <- gpava(y = y)$x aset.fitted <- activeSet(Atot, "LS", weights = w1, y = y)$x mse <- mean((pava.fitted - aset.fitted)^2) mse
Minimizes Efron's asymmetric least squares regression.
aSolver(z, a, extra)
aSolver(z, a, extra)
z |
Vector containing observed response |
a |
Matrix with active constraints |
extra |
List with element |
This function is called internally in activeSet
by setting mySolver = aSolver
.
x |
Vector containing the fitted values |
lbd |
Vector with Lagrange multipliers |
f |
Value of the target function |
gx |
Gradient at point x |
Efron, B. (1991). Regression percentiles using asymmetric squared error loss. Statistica Sinica, 1, 93-125.
##Fitting isotone regression using active set set.seed(12345) y <- rnorm(9) ##response values w <- rep(1,9) ##unit weights btota <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) fit.asy <- activeSet(btota, aSolver, weights = w, y = y, aw = 0.3, bw = 0.5)
##Fitting isotone regression using active set set.seed(12345) y <- rnorm(9) ##response values w <- rep(1,9) ##unit weights btota <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) fit.asy <- activeSet(btota, aSolver, weights = w, y = y, aw = 0.3, bw = 0.5)
Solver for the least absolute value norm with optional weights.
dSolver(z, a, extra)
dSolver(z, a, extra)
z |
Vector containing observed response |
a |
Matrix with active constraints |
extra |
List with element |
This function is called internally in activeSet
by setting mySolver = dSolver
.
x |
Vector containing the fitted values |
lbd |
Vector with Lagrange multipliers |
f |
Value of the target function |
gx |
Gradient at point x |
##Fitting weighted absolute norm problem set.seed(12345) y <- rnorm(9) ##response values w <- rep(1,9) ##unit weights btota <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) fit.abs <- activeSet(btota, dSolver, weights = w, y = y)
##Fitting weighted absolute norm problem set.seed(12345) y <- rnorm(9) ##response values w <- rep(1,9) ##unit weights btota <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) fit.abs <- activeSet(btota, dSolver, weights = w, y = y)
Solves an L1 approximation.
eSolver(z, a, extra)
eSolver(z, a, extra)
z |
Vector containing observed response |
a |
Matrix with active constraints |
extra |
List with element |
This function is called internally in activeSet
by setting mySolver = eSolver
.
x |
Vector containing the fitted values |
lbd |
Vector with Lagrange multipliers |
f |
Value of the target function |
gx |
Gradient at point x |
##Fitting isotone regression using active set set.seed(12345) y <- rnorm(9) ##response values w <- rep(1,9) ##unit weights eps = 0.01 ##error term btota <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) fit.approx <- activeSet(btota, eSolver, weights = w, y = y, eps = eps)
##Fitting isotone regression using active set set.seed(12345) y <- rnorm(9) ##response values w <- rep(1,9) ##unit weights eps = 0.01 ##error term btota <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) fit.approx <- activeSet(btota, eSolver, weights = w, y = y, eps = eps)
Specification of a differentiable convex loss function.
fSolver(z, a, extra)
fSolver(z, a, extra)
z |
Vector containing observed response |
a |
Matrix with active constraints |
extra |
List with element |
This function is called internally in activeSet
by setting mySolver = fSolver
. It uses
optim()
with "BFGS"
for optimization.
x |
Vector containing the fitted values |
lbd |
Vector with Lagrange multipliers |
f |
Value of the target function |
gx |
Gradient at point x |
##Fitting isotone regression using active set (L2-norm user-specified) set.seed(12345) y <- rnorm(9) ##response values w <- rep(1,9) ##unit weights btota <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) fit.convex <- activeSet(btota, fSolver, fobj = function(x) sum(w*(x-y)^2), gobj = function(x) 2*drop(w*(x-y)), y = y, weights = w)
##Fitting isotone regression using active set (L2-norm user-specified) set.seed(12345) y <- rnorm(9) ##response values w <- rep(1,9) ##unit weights btota <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) fit.convex <- activeSet(btota, fSolver, fobj = function(x) sum(w*(x-y)^2), gobj = function(x) 2*drop(w*(x-y)), y = y, weights = w)
Pooled-adjacent-violators algorithm for general isotone regression problems. It allows for general convex target function, multiple measurements, and different approaches for handling ties.
gpava(z, y, weights = NULL, solver = weighted.mean, ties = "primary", p = NA)
gpava(z, y, weights = NULL, solver = weighted.mean, ties = "primary", p = NA)
z |
Vector of abscissae values |
y |
Vector or list of vectors of responses |
weights |
Vector of list of vectors of observation weights |
solver |
Either |
ties |
Treatment of ties, either "primary", "secondary", or "tertiary" |
p |
Fractile value between 0 and 1 if |
A Pool Adjacent Violators Algorithm framework for minimizing problems like
under the constraint with
a convex function in m. Note that this formulation allows for repeated data in each block
(i.e. each list element of
y
, and hence is more general than the usual pava/isoreg ones.
A solver for the unconstrained can be specified.
Typical cases are
for
(solved by weighted mean) and
(solved by weighted median), respectively.
Using the weighted.fractile
solver corresponds to the classical minimization procedure in quantile regression.
The user can also specify his own function foo(y, w)
with responses and weights as arguments. It
should return a single numerical value.
Generates an object of class gpava
.
x |
Fitted values |
y |
Observed response |
z |
Observed predictors |
w |
Weights |
solver |
Convex function |
call |
Matched call |
p |
Fractile value |
Kurt Hornik, Jan de Leeuw, Patrick Mair
de Leeuw, J., Hornik, K., Mair, P. (2009). Isotone Optimization in R: Pool-Adjacent-Violators Algorithm (PAVA) and Active Set Methods. Journal of Statistical Software, 32(5), 1-24.
data(pituitary) ##different tie approaches gpava(pituitary[,1],pituitary[,2], ties = "primary") gpava(pituitary[,1],pituitary[,2], ties = "secondary") gpava(pituitary[,1],pituitary[,2], ties = "tertiary") ##different target functions gpava(pituitary[,1],pituitary[,2], solver = weighted.mean) gpava(pituitary[,1],pituitary[,2], solver = weighted.median) gpava(pituitary[,1],pituitary[,2], solver = weighted.fractile, p = 0.25) ##repeated measures data(posturo) res <- gpava(posturo[,1],posturo[,2:4], ties = "secondary") plot(res)
data(pituitary) ##different tie approaches gpava(pituitary[,1],pituitary[,2], ties = "primary") gpava(pituitary[,1],pituitary[,2], ties = "secondary") gpava(pituitary[,1],pituitary[,2], ties = "tertiary") ##different target functions gpava(pituitary[,1],pituitary[,2], solver = weighted.mean) gpava(pituitary[,1],pituitary[,2], solver = weighted.median) gpava(pituitary[,1],pituitary[,2], solver = weighted.fractile, p = 0.25) ##repeated measures data(posturo) res <- gpava(posturo[,1],posturo[,2:4], ties = "secondary") plot(res)
Solver for Huber's robust loss function.
hSolver(z, a, extra)
hSolver(z, a, extra)
z |
Vector containing observed response |
a |
Matrix with active constraints |
extra |
List with element |
This function is called internally in activeSet
by setting mySolver = hSolver
.
x |
Vector containing the fitted values |
lbd |
Vector with Lagrange multipliers |
f |
Value of the target function |
gx |
Gradient at point x |
Huber, P. (1982). Robust Statistics. Chichester: Wiley.
##Fitting isotone regression using active set set.seed(12345) y <- rnorm(9) ##response values w <- rep(1,9) ##unit weights eps <- 0.01 btota <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) fit.huber <- activeSet(btota, hSolver, weights = w, y = y, eps = eps)
##Fitting isotone regression using active set set.seed(12345) y <- rnorm(9) ##response values w <- rep(1,9) ##unit weights eps <- 0.01 btota <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) fit.huber <- activeSet(btota, hSolver, weights = w, y = y, eps = eps)
Minimizes soft insensitive loss function (SILF) for support vector regression.
iSolver(z, a, extra)
iSolver(z, a, extra)
z |
Vector containing observed response |
a |
Matrix with active constraints |
extra |
List with element |
This function is called internally in activeSet
by setting mySolver = iSolver
.
x |
Vector containing the fitted values |
lbd |
Vector with Lagrange multipliers |
f |
Value of the target function |
gx |
Gradient at point x |
Efron, B. (1991). Regression percentiles using asymmetric squared error loss. Statistica Sinica, 1, 93-125.
##Fitting isotone regression using active set set.seed(12345) y <- rnorm(9) ##response values w <- rep(1,9) ##unit weights eps <- 2 beta <- 0.4 btota <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) fit.silf <- activeSet(btota, iSolver, weights = w, y = y, beta = beta, eps = eps)
##Fitting isotone regression using active set set.seed(12345) y <- rnorm(9) ##response values w <- rep(1,9) ##unit weights eps <- 2 beta <- 0.4 btota <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) fit.silf <- activeSet(btota, iSolver, weights = w, y = y, beta = beta, eps = eps)
Solver for the general least squares monotone regression problem of the form (y-x)'W(y-x).
lfSolver(z, a, extra)
lfSolver(z, a, extra)
z |
Vector containing observed response |
a |
Matrix with active constraints |
extra |
List with element |
This function is called internally in activeSet
by setting mySolver = lfSolver
.
x |
Vector containing the fitted values |
lbd |
Vector with Lagrange multipliers |
f |
Value of the target function |
gx |
Gradient at point x |
##Fitting isotone regression set.seed(12345) y <- rnorm(9) ##response values w <- diag(rep(1,9)) ##unit weight matrix btota <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) #fit.lf <- activeSet(btota, lfSolver, weights = w, y = y)
##Fitting isotone regression set.seed(12345) y <- rnorm(9) ##response values w <- diag(rep(1,9)) ##unit weight matrix btota <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) #fit.lf <- activeSet(btota, lfSolver, weights = w, y = y)
Solver for the least squares monotone regression problem with optional weights.
lsSolver(z, a, extra)
lsSolver(z, a, extra)
z |
Vector containing observed response |
a |
Matrix with active constraints |
extra |
List with element |
This function is called internally in activeSet
by setting mySolver = lsSolver
.
x |
Vector containing the fitted values |
lbd |
Vector with Lagrange multipliers |
f |
Value of the target function |
gx |
Gradient at point x |
##Fitting isotone regression using active set set.seed(12345) y <- rnorm(9) ##response values w <- rep(1,9) ##unit weights btota <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) fit.ls <- activeSet(btota, lsSolver, weights = w, y = y)
##Fitting isotone regression using active set set.seed(12345) y <- rnorm(9) ##response values w <- rep(1,9) ##unit weights btota <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) fit.ls <- activeSet(btota, lsSolver, weights = w, y = y)
This dataset shows the number of freezing days at Lake Mendota measured from November, 23, in the year 1854.
data(mendota)
data(mendota)
A data frame with 12 subjects.
Bhattacharyya, G. K., & Klotz, J. H. (1966). The bivariate trend of Lake Mendota. Technical Report No. 98, Department of Statistics, University of Wisconsin.
Barlow, R. E., Bartholomew, D. J., Bremner, J. M., & Brunk, H. D. (1972). Statistical inference under order restrictions: The theory and application of isotonic regression. Chichester: Wiley.
data(mendota)
data(mendota)
The package contains three functions for fitting regressions with inequality restrictions:
mregnn
is the most general one, allowing basically for any partial orders, mregnnM
poses a monotone restriction on the fitted values, mregnnP
restricts the predicted values to be positive. Monre details can be found below.
mregnn(x, y, a) mregnnM(x, y) mregnnP(x, y)
mregnn(x, y, a) mregnnM(x, y) mregnnP(x, y)
x |
Can be a spline basis. |
y |
Response. |
a |
Matrix containing order restrictions. |
These functions solve the problem
over all for which
.
can be used require the transformation to be non-negative, or increasing, or satisfying any partial order.
xb |
Predicted values. |
lb |
Solution of the dual problem. |
f |
Value of the target function |
de Leeuw, J. (2015). Regression with Linear Inequality Restrictions on Predicted Values. http://rpubs.com/deleeuw/78897.
## Compute the best fitting quadratic polynomial (in black) ## and monotone quadratic polynomial (in blue) set.seed(12345) x <- outer(1:10,1:3,"^") x <- apply(x,2,function(x) x - mean(x)) x <- apply (x,2,function(x) x / sqrt (sum(x ^ 2))) y <- rowSums(x) + rnorm(10) plot(x[,1], y, lwd = 3, col = "RED", xlab = "x", ylab = "P(x)") o <- mregnnM(x,y) lines(x[,1], o$xb, col = "BLUE", lwd = 2) xb <- drop(x %*% qr.solve(x,y)) lines(x[,1],xb,col="BLACK", lwd = 2) ## same monotone model through basic mregnn() difmat <- function (n) { m1 <- ifelse(outer(1:(n - 1),1:n,"-") == -1, 1, 0) m2 <- ifelse(outer(1:(n - 1),1:n,"-") == 0,-1, 0) return (m1 + m2) } a <- difmat(nrow(x)) ## order restriction o2 <- mregnn(x, y, a)
## Compute the best fitting quadratic polynomial (in black) ## and monotone quadratic polynomial (in blue) set.seed(12345) x <- outer(1:10,1:3,"^") x <- apply(x,2,function(x) x - mean(x)) x <- apply (x,2,function(x) x / sqrt (sum(x ^ 2))) y <- rowSums(x) + rnorm(10) plot(x[,1], y, lwd = 3, col = "RED", xlab = "x", ylab = "P(x)") o <- mregnnM(x,y) lines(x[,1], o$xb, col = "BLUE", lwd = 2) xb <- drop(x %*% qr.solve(x,y)) lines(x[,1],xb,col="BLACK", lwd = 2) ## same monotone model through basic mregnn() difmat <- function (n) { m1 <- ifelse(outer(1:(n - 1),1:n,"-") == -1, 1, 0) m2 <- ifelse(outer(1:(n - 1),1:n,"-") == 0,-1, 0) return (m1 + m2) } a <- difmat(nrow(x)) ## order restriction o2 <- mregnn(x, y, a)
Solver for the Chebyshev norm.
mSolver(z, a, extra)
mSolver(z, a, extra)
z |
Vector containing observed response |
a |
Matrix with active constraints |
extra |
List with element |
This function is called internally in activeSet
by setting mySolver = mSolver
.
x |
Vector containing the fitted values |
lbd |
Vector with Lagrange multipliers |
f |
Value of the target function |
gx |
Gradient at point x |
##Fitting isotone regression using active set set.seed(12345) y <- rnorm(9) ##response values w <- rep(1,9) ##unit weights btota <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) fit.cheby <- activeSet(btota, mSolver, weights = w, y = y)
##Fitting isotone regression using active set set.seed(12345) y <- rnorm(9) ##response values w <- rep(1,9) ##unit weights btota <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) fit.cheby <- activeSet(btota, mSolver, weights = w, y = y)
Solver for Lp-norm.
oSolver(z, a, extra)
oSolver(z, a, extra)
z |
Vector containing observed response |
a |
Matrix with active constraints |
extra |
List with element |
This function is called internally in activeSet
by setting mySolver = oSolver
.
x |
Vector containing the fitted values |
lbd |
Vector with Lagrange multipliers |
f |
Value of the target function |
gx |
Gradient at point x |
##Fitting isotone regression set.seed(12345) y <- rnorm(9) ##normal distributed response values w1 <- rep(1,9) ##unit weights Atot <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) fit.pow <- activeSet(Atot, oSolver, y = y, weights = w1, p = 1.2)
##Fitting isotone regression set.seed(12345) y <- rnorm(9) ##normal distributed response values w1 <- rep(1,9) ##unit weights Atot <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) fit.pow <- activeSet(Atot, oSolver, y = y, weights = w1, p = 1.2)
The University of Carolina conducted a study in which the size (in mm) of the pituitary fissure was measured on girls between an age of 8 and 14.
data(pituitary)
data(pituitary)
A data frame with 11 subjects.
Pothoff, R. F., & Roy, S. N. (1964). A generalized multivariate analysis of variance model useful especially for growth curve problems. Biometrika, 51, 313-326.
Robertson, T., Wright, F. T., & Dykstra, R. L. (1988). Order restricted statistical inference. New York, Wiley.
data(pituitary)
data(pituitary)
This dataset represents a subset from the posturographic data collected in Leitner et al. (sensory organisation test SOT).
data(posturo)
data(posturo)
A data frame with 50 subjects, age as predictor and 3 repeated SOT measures as responses.
Leitner, C., Mair, P., Paul, B., Wick, F., Mittermaier, C., Sycha, T., & Ebenbichler, G. (2009). Reliability of posturographic measurements in the assessment of impaired sensorimotor function in chronic low back pain. Journal of Electromyography and Kinesiology, 19(3), 380-390.
data(posturo)
data(posturo)
Solver for the general p-quantile monotone regression problem with optional weights.
pSolver(z, a, extra)
pSolver(z, a, extra)
z |
Vector containing observed response |
a |
Matrix with active constraints |
extra |
List with element |
This function is called internally in activeSet
by setting mySolver = pSolver
. Note
that if aw
= bw
, we get the weighted median and therefore we solved the weighted absolute norm.
x |
Vector containing the fitted values |
lbd |
Vector with Lagrange multipliers |
f |
Value of the target function |
gx |
Gradient at point x |
Koenker, R. (2005). Quantile regression. Cambridge, MA: Cambridge University Press.
##Fitting quantile regression set.seed(12345) y <- rnorm(9) ##response values w <- rep(1,9) ##unit weights btota <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) fit.p <- activeSet(btota, pSolver, weights = w, y = y, aw = 0.3, bw = 0.7)
##Fitting quantile regression set.seed(12345) y <- rnorm(9) ##response values w <- rep(1,9) ##unit weights btota <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) fit.p <- activeSet(btota, pSolver, weights = w, y = y, aw = 0.3, bw = 0.7)
Solver for the negative Poisson log-likelihood
sSolver(z, a, extra)
sSolver(z, a, extra)
z |
Vector containing observed response |
a |
Matrix with active constraints |
extra |
List with element |
This function is called internally in activeSet
by setting mySolver = sSolver
.
x |
Vector containing the fitted values |
lbd |
Vector with Lagrange multipliers |
f |
Value of the target function |
gx |
Gradient at point x |
##Minimizing Poisson log-liklihood set.seed(12345) yp <- rpois(9,5) Atot <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) x0 <- 1:9 ##starting values fit.poi <- activeSet(Atot, sSolver, x0 = x0, y = yp)
##Minimizing Poisson log-liklihood set.seed(12345) yp <- rpois(9,5) Atot <- cbind(1:8, 2:9) ##Matrix defining isotonicity (total order) x0 <- 1:9 ##starting values fit.poi <- activeSet(Atot, sSolver, x0 = x0, y = yp)
Computes the weighted fractile of a numeric vector
weighted.fractile(y, w, p)
weighted.fractile(y, w, p)
y |
A numeric vector containing the values whose fractile is to be computed |
w |
A vector of length |
p |
Fractile specification; value between 0 and 1 |
weighted.mean
, weighted.median
y <- 1:9 w <- c(rep(1,5), rep(2,4)) res <- weighted.fractile(y, w, p = 0.33)
y <- 1:9 w <- c(rep(1,5), rep(2,4)) res <- weighted.fractile(y, w, p = 0.33)
Computes a weighted median of a numeric vector
weighted.median(y, w)
weighted.median(y, w)
y |
A numeric vector containing the values whose median is to be computed |
w |
A vector of length |
weighted.mean
, weighted.fractile
y <- 1:9 w <- c(rep(1,5), rep(2,4)) res <- weighted.median(y, w)
y <- 1:9 w <- c(rep(1,5), rep(2,4)) res <- weighted.median(y, w)