Question 1

(a) 6.6 c.

Data = read.table("http://users.stat.ufl.edu/~rrandles/sta4210/Rclassnotes/data/textdatasets/KutnerData/Chapter%20%206%20Data%20Sets/CH06PR05.txt")
#Brand Preferences
names(Data) = c("Brand_Liking", "Moisture","Sweetness")
n <- nrow(Data)  
fit_all<- lm(Brand_Liking~., data=Data)
summary(fit_all)
## 
## Call:
## lm(formula = Brand_Liking ~ ., data = Data)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -4.400 -1.762  0.025  1.587  4.200 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  37.6500     2.9961  12.566 1.20e-08 ***
## Moisture      4.4250     0.3011  14.695 1.78e-09 ***
## Sweetness     4.3750     0.6733   6.498 2.01e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.693 on 13 degrees of freedom
## Multiple R-squared:  0.9521, Adjusted R-squared:  0.9447 
## F-statistic: 129.1 on 2 and 13 DF,  p-value: 2.658e-09
alphaF=0.01
g=2
confint(fit_all, level=1-alphaF/g)
##                0.25 %   99.75 %
## (Intercept) 27.545738 47.754262
## Moisture     3.409483  5.440517
## Sweetness    2.104236  6.645764

(b) 6.8 a.

new <- data.frame(Moisture=c(5),Sweetness=c(4))
g=nrow(new)
alpha=0.01
BCI=predict(fit_all,new,se.fit = TRUE, interval = "confidence",level=1-alphaF/g)
BCI$fit
##      fit      lwr      upr
## 1 77.275 73.88111 80.66889

(c) 6.8 b.

predict(fit_all,new, interval = "predict",level=1-alpha)
##      fit      lwr      upr
## 1 77.275 68.48077 86.06923

Question 2

(a) 6.18 c.

CProp=read.table("http://users.stat.ufl.edu/~rrandles/sta4210/Rclassnotes/data/textdatasets/KutnerData/Chapter%20%206%20Data%20Sets/CH06PR18.txt")
names(CProp) = c("Rental_Rates", "Age","Operating_Expenses", "Vacancy_Rates", "Square_Footage")
n <- nrow(CProp)  
p =ncol(CProp)
fit_CProp<- lm(Rental_Rates~., data=CProp)
summary(fit_CProp)
## 
## Call:
## lm(formula = Rental_Rates ~ ., data = CProp)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.1872 -0.5911 -0.0910  0.5579  2.9441 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)         1.220e+01  5.780e-01  21.110  < 2e-16 ***
## Age                -1.420e-01  2.134e-02  -6.655 3.89e-09 ***
## Operating_Expenses  2.820e-01  6.317e-02   4.464 2.75e-05 ***
## Vacancy_Rates       6.193e-01  1.087e+00   0.570     0.57    
## Square_Footage      7.924e-06  1.385e-06   5.722 1.98e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.137 on 76 degrees of freedom
## Multiple R-squared:  0.5847, Adjusted R-squared:  0.5629 
## F-statistic: 26.76 on 4 and 76 DF,  p-value: 7.272e-14
#Commercial Properties
fit_CProp$coefficients
##        (Intercept)                Age Operating_Expenses 
##       1.220059e+01      -1.420336e-01       2.820165e-01 
##      Vacancy_Rates     Square_Footage 
##       6.193435e-01       7.924302e-06

\(\widehat{Rental_{}Rates} = 12.2 - 0.142Age + 0.282Operating_{}Expenses + 0.619Vacancy_{}Rates + 0.00000792Square_{}Footage\)

or better written as \(\hat{Y} = 12.2 - 0.142X_1 + 0.282X_2 + 0.619X_3 + 0.00000792X_4\)

(b) 6.19 a.

summary(fit_CProp)
## 
## Call:
## lm(formula = Rental_Rates ~ ., data = CProp)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.1872 -0.5911 -0.0910  0.5579  2.9441 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)         1.220e+01  5.780e-01  21.110  < 2e-16 ***
## Age                -1.420e-01  2.134e-02  -6.655 3.89e-09 ***
## Operating_Expenses  2.820e-01  6.317e-02   4.464 2.75e-05 ***
## Vacancy_Rates       6.193e-01  1.087e+00   0.570     0.57    
## Square_Footage      7.924e-06  1.385e-06   5.722 1.98e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.137 on 76 degrees of freedom
## Multiple R-squared:  0.5847, Adjusted R-squared:  0.5629 
## F-statistic: 26.76 on 4 and 76 DF,  p-value: 7.272e-14

\[H_0: \beta_1 = \beta_2 = \beta_3 = \beta_4 = 0 \] \[H_a: At~least~1~\beta_k \neq 0~for~k = 1, 2, 3, 4 \]

With F = 26.76 and a p-value of 7.272e-14 < \(\alpha=0.05\), we reject the null and conclude that At least 1 \(\beta_k \neq 0\) for k =1,2,3,4.

(b) 6.19 b.

alphaF=0.05
g=4
confint(fit_CProp, level=1-alphaF/g)
##                          0.625 %      99.375 %
## (Intercept)         1.072186e+01  1.367931e+01
## Age                -1.966396e-01 -8.742769e-02
## Operating_Expenses  1.203875e-01  4.436456e-01
## Vacancy_Rates      -2.161312e+00  3.399999e+00
## Square_Footage      4.381297e-06  1.146731e-05

(b) 6.19 c.

summary(fit_CProp)
## 
## Call:
## lm(formula = Rental_Rates ~ ., data = CProp)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.1872 -0.5911 -0.0910  0.5579  2.9441 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)         1.220e+01  5.780e-01  21.110  < 2e-16 ***
## Age                -1.420e-01  2.134e-02  -6.655 3.89e-09 ***
## Operating_Expenses  2.820e-01  6.317e-02   4.464 2.75e-05 ***
## Vacancy_Rates       6.193e-01  1.087e+00   0.570     0.57    
## Square_Footage      7.924e-06  1.385e-06   5.722 1.98e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.137 on 76 degrees of freedom
## Multiple R-squared:  0.5847, Adjusted R-squared:  0.5629 
## F-statistic: 26.76 on 4 and 76 DF,  p-value: 7.272e-14

\(R^2\) is .5847. This means that 58.47% of the variation in mean rental rate is explained by the linear relationship with Age, Operating Expenses, Vacancy Rates, and Square Footage.

(c) 6.20

new <- data.frame(Age=c(5,6,14,12), Operating_Expenses=c(8.25, 8.5, 11.5, 10.25), Vacancy_Rates=c(0, .23, .11, 0), Square_Footage = c(250000, 270000, 300000, 310000))
g=nrow(new)
alphaF=0.05
#Bonferroni CI
BCI=predict(fit_CProp,new,se.fit = TRUE, interval = "confidence",level=1-alphaF/g)
BCI$fit
##        fit      lwr      upr
## 1 15.79813 15.08664 16.50962
## 2 16.02754 15.42391 16.63116
## 3 15.90072 15.33232 16.46913
## 4 15.84339 15.18040 16.50638
#Working-Hotelling CI 
Yh_hat=predict(fit_CProp,newdata=new)
W=sqrt(p*qf(1-alphaF,p,n-p))
WHCI=cbind(Yh_hat,Yh_hat-W*BCI$se.fit,Yh_hat+W*BCI$se.fit)
colnames(WHCI)=c("fitted","lower","upper")
rownames(WHCI)=c("1","2", "3", "4")
WHCI
##     fitted    lower    upper
## 1 15.79813 14.84797 16.74829
## 2 16.02754 15.22142 16.83365
## 3 15.90072 15.14165 16.65980
## 4 15.84339 14.95799 16.72878
#Need to compare the multiplier
t=qt((1-alphaF/g/2),(n-p))
list(W,t)
## [[1]]
## [1] 3.416811
## 
## [[2]]
## [1] 2.558541
#t is  smaller. Use Bonferroni method.
BCI$fit
##        fit      lwr      upr
## 1 15.79813 15.08664 16.50962
## 2 16.02754 15.42391 16.63116
## 3 15.90072 15.33232 16.46913
## 4 15.84339 15.18040 16.50638