Learn R Programming

coneproj (version 1.2)

coneA: Cone Projection -- Polar Cone

Description

This routine implements the hinge algorithm for cone projection to minimize $||y - \theta||^2$ over the cone $C$ of the form ${\theta: A\theta \ge 0}$.

Usage

coneA(y, amat, w = NULL)

Arguments

y
A vector of length $n$.
amat
A constraint matrix. The rows of amat must be irreducible. The column number of amat must equal the length of $y$.
w
An optional nonnegative vector of weights of length $n$. If w is not given, all weights are taken to equal 1. Otherwise, the minimization of $(y - \theta)'w(y - \theta)$ over $C$ is returned. The default is w = NULL.

Value

  • dfThe dimension of the face of the constraint cone on which the projection lands.
  • thetahatThe projection of $y$ on the constraint cone.
  • stepsThe number of iterations before the algorithm converges.

Details

The routine coneA dynamically loads a C++ subroutine "coneACpp". The rows of $- A$ are the edges of the polar cone $\Omega^o$. This routine first projects $y$ onto $\Omega^o$ to get the residual of the projection onto the constraint cone $C$, and then uses the fact that $y$ is equal to the sum of the projection of $y$ onto $C$ and the projection of $y$ onto $\Omega^o$ to get the estimation of $\theta$. See references cited in this section for more details about the relationship between polar cone and constraint cone.

References

Meyer, M. C. (1999) An extension of the mixed primal-dual bases algorithm to the case of more constraints than dimensions. Journal of Statistical Planning and Inference 81, 13--31. Meyer, M. C. (2013b) A simple new algorithm for quadratic programming with applications in statistics. Communications in Statistics 42(5), 1126--1139.

See Also

coneB, constreg, qprog

Examples

Run this code
#generate y
    set.seed(123)
    n <- 50
    x <- seq(-2, 2, length = 50)
    y <- - x^2 + rnorm(n)

#create the constraint matrix to make the first half of y monotonically increasing
#and the second half of y monotonically decreasing
    amat <- matrix(0, n - 1, n)
    for(i in 1:(n/2 - 1)){
       amat[i, i] <- -1; amat[i, i + 1] <- 1
    }
    for(i in (n/2):(n - 1)){
       amat[i, i] <- 1; amat[i, i + 1] <- -1
    }

#call coneA
    ans1 <- coneA(y, amat)
    ans2 <- coneA(y, amat, w = (1:n)/n)

#make a plot to compare the unweighted fit and the weighted fit
    par(mar = c(4, 4, 1, 1))
    plot(y, cex = .7, ylab = "y")
    lines(ans1$thetahat, col = 2, lty = 2)
    lines(ans2$thetahat, col = 4, lty = 2)
    legend("topleft", bty = "n", c("unweighted fit", "weighted fit"), col = c(2, 4), lty = c(2, 2))
    title("ConeA Example Plot")

Run the code above in your browser using DataLab