In: Statistics and Probability
Fitting a linear model using R a. Read the Toluca.txt dataset into R (this dataset can be found on Canvas). Now fit a simple linear regression model with X = lotSize and Y = workHrs. Summarize the output from the model: the least square estimators, their standard errors, and corresponding p-values. b. Draw the scatterplot of Y versus X and add the least squares line to the scatterplot. c. Obtain the fitted values ˆyi and residuals ei . Print the first 5 fitted values and the corresponding residuals.
lotSize workHrs
80 399
30 121
50 221
90 376
70 361
60 224
120 546
80 352
100 353
50 157
40 160
70 252
90 389
20 113
110 435
100 420
30 212
50 268
90 377
110 421
30 273
90 468
40 244
80 342
70 323
Given data
Toluca |
|
x |
y |
80 |
399 |
30 |
121 |
50 |
221 |
90 |
376 |
70 |
361 |
60 |
224 |
120 |
546 |
80 |
352 |
100 |
353 |
50 |
157 |
40 |
160 |
70 |
252 |
90 |
389 |
20 |
113 |
110 |
435 |
100 |
420 |
30 |
212 |
50 |
268 |
90 |
377 |
110 |
421 |
30 |
273 |
90 |
468 |
40 |
244 |
80 |
342 |
70 |
323 |
Answer(a): the least square estimators, their standard errors, and corresponding p-values
Coefficients: |
|||||
Estimate |
Std. |
Error |
t |
value Pr(>|t|) |
|
(Intercept) |
62.366 |
26.177 |
2.382 |
0.0259 |
* |
x |
3.57 |
0.347 |
10.29 |
4.45E-10 |
*** |
Answer(b): scatterplot of Y versus X and the least squares line to the scatterplot
Answer(C): First five fitted values yi and residuals ei
y |
y fitted |
errors |
399 |
347.982 |
51.01798 |
121 |
169.4719 |
-48.4719 |
221 |
240.876 |
-19.876 |
376 |
383.684 |
-7.68404 |
361 |
312.28 |
48.72 |