pcls: Positive and unit sum constrained least squares

View source: R/pcls.R

Positive and unit sum constrained least squaresR Documentation

Positive and unit sum constrained least squares

Description

Positive and unit sum constrained least squares.

Usage

pcls(y, x)
mpcls(y, x)

Arguments

y

The response variable. For the pcls() a numerical vector with observations, but for the mpcls() a numerical matrix.

x

A matrix with independent variables, the design matrix.

Details

The constraint is that all beta coefficients are positive and sum to 1. That is min \sum_{i=1}^n(y_i-\bm{x}_i\top\bm{\beta})^2 such that 0\leq \beta_j \leq 1 and \sum_{j=1}^d\beta_j=1. The pcls() function performs a single regression model, whereas the mpcls() function performs a regression for each column of y. Each regression is independent of the others.

Value

A list including:

coefficients

A numerical matrix with the positively constrained beta coefficients.

value

A numerical vector with the mean squared error.

Author(s)

Michail Tsagris.

R implementation and documentation: Michail Tsagris mtsagris@uoc.gr.

See Also

kld, mkld

Examples

x <- matrix(runif(30 * 8), ncol = 30)
x <- t( x / rowSums(x) )
y <- runif(30)
y <- y / sum(y)
pcls(y, x)

scpropreg documentation built on March 24, 2026, 5:07 p.m.