Eigen_lsSolve: Linear least-squares problems

View source: R/EigenR.R

Eigen_lsSolveR Documentation

Linear least-squares problems

Description

Solves a linear least-squares problem.

Usage

Eigen_lsSolve(A, b, method = "cod")

Arguments

A

a n*p matrix, real or complex

b

a vector of length n or a matrix with n rows, real or complex

method

the method used to solve the problem, either "svd" (based on the SVD decomposition) or "cod" (based on the complete orthogonal decomposition)

Value

The solution X of the least-squares problem AX ~= b (similar to lm.fit(A, b)$coefficients). This is a matrix if b is a matrix, or a vector if b is a vector.

Examples

set.seed(129)
n <- 7; p <- 2
A <- matrix(rnorm(n * p), n, p)
b <- rnorm(n)
lsfit <- Eigen_lsSolve(A, b)
b - A %*% lsfit # residuals

EigenR documentation built on May 18, 2022, 9:05 a.m.