Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
4
Task/Multiple-regression/R/multiple-regression-1.r
Normal file
4
Task/Multiple-regression/R/multiple-regression-1.r
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
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))
|
||||
16
Task/Multiple-regression/R/multiple-regression-2.r
Normal file
16
Task/Multiple-regression/R/multiple-regression-2.r
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
simpleMultipleReg <- function(formula) {
|
||||
|
||||
## parse and evaluate the model formula
|
||||
mf <- model.frame(formula)
|
||||
|
||||
## create design matrix
|
||||
X <- model.matrix(mf)
|
||||
|
||||
## create dependent variable
|
||||
Y <- model.response(mf)
|
||||
|
||||
## solve
|
||||
solve(t(X) %*% X) %*% t(X) %*% Y
|
||||
}
|
||||
|
||||
simpleMultipleReg(y ~ x + I(x^2))
|
||||
1
Task/Multiple-regression/R/multiple-regression-3.r
Normal file
1
Task/Multiple-regression/R/multiple-regression-3.r
Normal file
|
|
@ -0,0 +1 @@
|
|||
solve(crossprod(X), crossprod(X, Y))
|
||||
21
Task/Multiple-regression/R/multiple-regression-4.r
Normal file
21
Task/Multiple-regression/R/multiple-regression-4.r
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
lm.impl <- function(formula) {
|
||||
mf <- model.frame(formula)
|
||||
X <- model.matrix(mf)
|
||||
Y <- model.response(mf)
|
||||
qr.coef(qr(X), Y)
|
||||
}
|
||||
|
||||
|
||||
lm(y ~ x + I(x^2))
|
||||
|
||||
# Call:
|
||||
# lm(formula = y ~ x + I(x^2))
|
||||
#
|
||||
# Coefficients:
|
||||
# (Intercept) x I(x^2)
|
||||
# 128.81 -143.16 61.96
|
||||
|
||||
lm.impl(y ~ x + I(x^2))
|
||||
|
||||
# (Intercept) x I(x^2)
|
||||
# 128.81280 -143.16202 61.96033
|
||||
Loading…
Add table
Add a link
Reference in a new issue