mnls: Minimum Norm Least Squares

Description Usage Arguments Details Value Author(s) Examples

View source: R/mnls.R

Description

mnls computes the minimum norm solution to the least squares problem.

Usage

1
mnls(x, y, rcond = 1e-10)

Arguments

x

design matrix of dimension n by p.

y

response vector of length n, or response matrix of dimension n by q.

rcond

reciprocal condition number to determine the effective rank of x.

Details

The underlying C code calls the LAPACK routine DGELSY.

Value

The least squares solution, as a p by q matrix. It has an attribute called rank, which is the effective rank of x.

Author(s)

Yichi Zhang

Examples

1
2
3
4
5
x <- matrix(rnorm(500L), 100L, 5L)
x <- cbind(x, x[, 1L] + x[, 2L], x[, 1L] - x[, 3L])
b <- -3L : 3L
y <- c(x %*% b)
mnls(x, y)  # different to b

Example output

              [,1]
[1,]  2.220446e-16
[2,] -7.216450e-16
[3,] -2.000000e+00
[4,] -2.389247e-16
[5,]  1.000000e+00
[6,]  0.000000e+00
[7,]  2.000000e+00
attr(,"rank")
[1] 5

lmeVarComp documentation built on May 2, 2019, 8:55 a.m.

Related to mnls in lmeVarComp...