MATH 376 -- Mathematical Statistics First Multiple Regression Examples April 16, 2012 A) Fitting a model Y = beta_0 + beta_1 x_1 + beta_2 x_2 + epsilon to the data (0,0,4), (1,2,3), (1,0,5), (0,1,7) (geometrically, this is finding a plane coming closest to those four data points in R^3) > x1 <- c(0,1,1,0) > x2 <- c(0,2,0,1) > y <- c(4,3,5,7) > firstex <- lm(y ~ x1 + x2) > summary(firstex) Call: lm(formula = y ~ x1 + x2) Residuals: 1 2 3 4 -1.6 -0.8 0.8 1.6 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 5.600 1.960 2.858 0.214 x1 -1.400 2.653 -0.528 0.691 x2 -0.200 1.600 -0.125 0.921 Residual standard error: 2.53 on 1 degrees of freedom Multiple R-squared: 0.2686, Adjusted R-squared: -1.194 F-statistic: 0.1836 on 2 and 1 DF, p-value: 0.8552 B) Fitting a model Y = beta_0 + beta_1 x + beta_2 x^2 + epsilon to the data (0,1), (1,4), (2,7), (3,8) > x <- c(0,1,2,3) > y <- c(1,4,7,8) > secondex <- lm(y ~ x + I(x^2)) > summary(secondex) Call: lm(formula = y ~ x + I(x^2)) Residuals: 1 2 3 4 0.1 -0.3 0.3 -0.1 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.9000 0.4359 2.065 0.287 x 3.9000 0.7000 5.571 0.113 I(x^2) -0.5000 0.2236 -2.236 0.268 Residual standard error: 0.4472 on 1 degrees of freedom Multiple R-squared: 0.9933, Adjusted R-squared: 0.98 F-statistic: 74.5 on 2 and 1 DF, p-value: 0.08165