LSfitNonNeg | R Documentation |
Assuming z = t(x) %*% y + noise
, a non-negatively modified least squares estimate of t(x) %*% y
is made.
LSfitNonNeg(x, z, limit = 1e-10, viaQR = FALSE, printInc = TRUE)
x |
A matrix |
z |
A single column matrix |
limit |
Lower limit for non-zero fits. Set to |
viaQR |
Least squares fits obtained using |
printInc |
Printing "..." to console when |
The problem is first reduced by elimination some rows of x
(elements of y
) using GaussIndependent
.
Thereafter least squares fits are obtained using solve
or qr
.
Possible negative fits will be forced to zero in the next estimation iteration(s).
A fitted version of z
Øyvind Langsrud
set.seed(123)
data2 <- SSBtoolsData("z2")
x <- ModelMatrix(data2, formula = ~fylke + kostragr * hovedint - 1)
z <- t(x) %*% data2$ant + rnorm(ncol(x), sd = 3)
LSfitNonNeg(x, z)
LSfitNonNeg(x, z, limit = NULL)
## Not run:
mf <- ~region*mnd + hovedint*mnd + fylke*hovedint*mnd + kostragr*hovedint*mnd
data4 <- SSBtoolsData("sosialFiktiv")
x <- ModelMatrix(data4, formula = mf)
z <- t(x) %*% data4$ant + rnorm(ncol(x), sd = 3)
zFit <- LSfitNonNeg(x, z)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.