-
Description :
-
The least squares estimate of b in the model y = X b + e is found.
-
lsfit(x, y, wt = NULL, intercept = TRUE, tolerance = 1e-07, yname = NULL)
-
x : a matrix whose rows correspond to cases and whose columns correspond to variables.
y : the responses, possibly a matrix if you want to fit multiple left hand sides.
wt : an optional vector of weights for performing weighted least squares.
x <- c(70, 72, 62, 64, 71, 76, 60, 65, 74, 72) y <- c(70, 74, 65, 68, 72, 74, 61, 66, 76, 75) z <- lsfit(x, y) print(z) plot(x,y-z$residual,xlim=c(min(x),max(x)),ylim=c(min(y),max(y)),type="l") par(new=T) plot(x,y,xlim=c(min(x),max(x)),ylim=c(min(y),max(y)))
