ANSWER: p-value: 0.05296
x <- c(0.61, 0.93, 0.83, 0.35, 0.54, 0.16, 0.91, 0.62, 0.62)
y <- c(0.67, 0.84, 0.6, 0.18, 0.85, 0.47, 1.1, 0.65, 0.36)
xy <- lm( y ~ x)
summary(xy)
##
## Call:
## lm(formula = y ~ x)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.27636 -0.18807 0.01364 0.16595 0.27143
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.1885 0.2061 0.914 0.391
## x 0.7224 0.3107 2.325 0.053 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.223 on 7 degrees of freedom
## Multiple R-squared: 0.4358, Adjusted R-squared: 0.3552
## F-statistic: 5.408 on 1 and 7 DF, p-value: 0.05296
ANSWER: 0.223
ANSWER: 18.99
regcarmodel <- lm(mpg ~ wt, data = mtcars)
# mpg = outcome
# wt = predictor
meanvalue = data.frame(wt = mean(mtcars$wt))
predict(regcarmodel, meanvalue, interval = "confidence")
## fit lwr upr
## 1 20.09062 18.99098 21.19027
ANSWER: The estimated expected change in mpg per 1000 lb increase in weight.
ANSWER: 27.57
newvalue = data.frame(wt=3)
predict(regcarmodel, newvalue, interval = "predict")
## fit lwr upr
## 1 21.25171 14.92987 27.57355
ANSWER: -12.97
newmodel <- lm(mpg ~ I(wt/2), data = mtcars)
newsumm <- summary(newmodel)$coefficients
# print the summary for the new model
newsumm
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 37.28513 1.877627 19.857575 8.241799e-19
## I(wt/2) -10.68894 1.118202 -9.559044 1.293959e-10
# calculate the confidence interval for the slope
newsumm[2,1] + c(-1,1)*qt(.975, df = newmodel$df)*newsumm[2,2]
## [1] -12.97262 -8.40527
y = beta0 + beta1x x(cm)1/100(cm) = 1/100(m) beta1 = (y - beta0)/x
ANSWER: It would get multiplied by 100.
Shifting x with a constant variable does not change the slope but it affects the intercept.
y = beta0 - c.beta1 + beta1(x + c) + error
ANSWER: beta0-hat - c.beta1-hat
ANSWER: 0.25
carmodel1 <- lm(mpg ~ wt, data = mtcars)
carmodel2 <- lm(mpg ~ 1, data = mtcars)
num <- sum(resid(carmodel1)^2)
den <- sum(resid(carmodel2)^2)
ratio <- num/den
ratio
## [1] 0.2471672
ANSWER: If an intercept is included, then they will sum to 0.