This commit is contained in:
Ingy döt Net 2013-04-10 21:29:02 -07:00
parent 764da6cbbb
commit db842d013d
19005 changed files with 197040 additions and 7 deletions

View file

@ -0,0 +1,6 @@
## Wikipedia Data
x <- c(1.47, 1.50, 1.52, 1.55, 1.57, 1.60, 1.63, 1.65, 1.68, 1.70, 1.73, 1.75, 1.78, 1.80, 1.83)
}
y <- c(52.21, 53.12, 54.48, 55.84, 57.20, 58.57, 59.93, 61.29, 63.11, 64.47, 66.28, 68.10, 69.92, 72.19, 74.46)
lm( y ~ x + I(x^2))

View file

@ -0,0 +1,16 @@
simpleMultipleReg <- function(formula) {
## parse and evaluate the model formula
mf <- model.frame(formula)
## create design matrix
X <- model.matrix(attr(mf, "terms"), mf)
## create dependent variable
Y <- model.response(mf)
## solve
solve(t(X) %*% X) %*% t(X) %*% Y
}
simpleMultipleReg(y ~ x + I(x^2))

View file

@ -0,0 +1 @@
solve( crossprod(X), crossprod(X, Y))