### Setup
getwd()
## [1] "C:/Users/Jerome/Documents/0000_Work_Files/0000_Montgomery_College/Data_Science_101/Data_101_Fall_2022/Homework_12_Due_28Nov28/IC11_Regression_Practice"
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6      ✔ purrr   0.3.5 
## ✔ tibble  3.1.8      ✔ dplyr   1.0.10
## ✔ tidyr   1.2.1      ✔ stringr 1.4.1 
## ✔ readr   2.1.3      ✔ forcats 0.5.2 
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(dplyr)
library(psych)
## Warning: package 'psych' was built under R version 4.2.2
## 
## Attaching package: 'psych'
## 
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
library(infer)
library(ggplot2)
### Read the Data
day <- read_csv("day.csv")
## Rows: 731 Columns: 16
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl  (15): instant, season, yr, mnth, holiday, weekday, workingday, weathers...
## date  (1): dteday
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
### Examine the Data

str(day)
## spec_tbl_df [731 × 16] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
##  $ instant   : num [1:731] 1 2 3 4 5 6 7 8 9 10 ...
##  $ dteday    : Date[1:731], format: "2011-01-01" "2011-01-02" ...
##  $ season    : num [1:731] 1 1 1 1 1 1 1 1 1 1 ...
##  $ yr        : num [1:731] 0 0 0 0 0 0 0 0 0 0 ...
##  $ mnth      : num [1:731] 1 1 1 1 1 1 1 1 1 1 ...
##  $ holiday   : num [1:731] 0 0 0 0 0 0 0 0 0 0 ...
##  $ weekday   : num [1:731] 6 0 1 2 3 4 5 6 0 1 ...
##  $ workingday: num [1:731] 0 0 1 1 1 1 1 0 0 1 ...
##  $ weathersit: num [1:731] 2 2 1 1 1 1 2 2 1 1 ...
##  $ temp      : num [1:731] 0.344 0.363 0.196 0.2 0.227 ...
##  $ atemp     : num [1:731] 0.364 0.354 0.189 0.212 0.229 ...
##  $ hum       : num [1:731] 0.806 0.696 0.437 0.59 0.437 ...
##  $ windspeed : num [1:731] 0.16 0.249 0.248 0.16 0.187 ...
##  $ casual    : num [1:731] 331 131 120 108 82 88 148 68 54 41 ...
##  $ registered: num [1:731] 654 670 1229 1454 1518 ...
##  $ cnt       : num [1:731] 985 801 1349 1562 1600 ...
##  - attr(*, "spec")=
##   .. cols(
##   ..   instant = col_double(),
##   ..   dteday = col_date(format = ""),
##   ..   season = col_double(),
##   ..   yr = col_double(),
##   ..   mnth = col_double(),
##   ..   holiday = col_double(),
##   ..   weekday = col_double(),
##   ..   workingday = col_double(),
##   ..   weathersit = col_double(),
##   ..   temp = col_double(),
##   ..   atemp = col_double(),
##   ..   hum = col_double(),
##   ..   windspeed = col_double(),
##   ..   casual = col_double(),
##   ..   registered = col_double(),
##   ..   cnt = col_double()
##   .. )
##  - attr(*, "problems")=<externalptr>
head(day)
## # A tibble: 6 × 16
##   instant dteday     season    yr  mnth holiday weekday workingday weath…¹  temp
##     <dbl> <date>      <dbl> <dbl> <dbl>   <dbl>   <dbl>      <dbl>   <dbl> <dbl>
## 1       1 2011-01-01      1     0     1       0       6          0       2 0.344
## 2       2 2011-01-02      1     0     1       0       0          0       2 0.363
## 3       3 2011-01-03      1     0     1       0       1          1       1 0.196
## 4       4 2011-01-04      1     0     1       0       2          1       1 0.2  
## 5       5 2011-01-05      1     0     1       0       3          1       1 0.227
## 6       6 2011-01-06      1     0     1       0       4          1       1 0.204
## # … with 6 more variables: atemp <dbl>, hum <dbl>, windspeed <dbl>,
## #   casual <dbl>, registered <dbl>, cnt <dbl>, and abbreviated variable name
## #   ¹​weathersit
tail(day)
## # A tibble: 6 × 16
##   instant dteday     season    yr  mnth holiday weekday workingday weath…¹  temp
##     <dbl> <date>      <dbl> <dbl> <dbl>   <dbl>   <dbl>      <dbl>   <dbl> <dbl>
## 1     726 2012-12-26      1     1    12       0       3          1       3 0.243
## 2     727 2012-12-27      1     1    12       0       4          1       2 0.254
## 3     728 2012-12-28      1     1    12       0       5          1       2 0.253
## 4     729 2012-12-29      1     1    12       0       6          0       2 0.253
## 5     730 2012-12-30      1     1    12       0       0          0       1 0.256
## 6     731 2012-12-31      1     1    12       0       1          1       2 0.216
## # … with 6 more variables: atemp <dbl>, hum <dbl>, windspeed <dbl>,
## #   casual <dbl>, registered <dbl>, cnt <dbl>, and abbreviated variable name
## #   ¹​weathersit
summary(day)
##     instant          dteday               season            yr        
##  Min.   :  1.0   Min.   :2011-01-01   Min.   :1.000   Min.   :0.0000  
##  1st Qu.:183.5   1st Qu.:2011-07-02   1st Qu.:2.000   1st Qu.:0.0000  
##  Median :366.0   Median :2012-01-01   Median :3.000   Median :1.0000  
##  Mean   :366.0   Mean   :2012-01-01   Mean   :2.497   Mean   :0.5007  
##  3rd Qu.:548.5   3rd Qu.:2012-07-01   3rd Qu.:3.000   3rd Qu.:1.0000  
##  Max.   :731.0   Max.   :2012-12-31   Max.   :4.000   Max.   :1.0000  
##       mnth          holiday           weekday        workingday   
##  Min.   : 1.00   Min.   :0.00000   Min.   :0.000   Min.   :0.000  
##  1st Qu.: 4.00   1st Qu.:0.00000   1st Qu.:1.000   1st Qu.:0.000  
##  Median : 7.00   Median :0.00000   Median :3.000   Median :1.000  
##  Mean   : 6.52   Mean   :0.02873   Mean   :2.997   Mean   :0.684  
##  3rd Qu.:10.00   3rd Qu.:0.00000   3rd Qu.:5.000   3rd Qu.:1.000  
##  Max.   :12.00   Max.   :1.00000   Max.   :6.000   Max.   :1.000  
##    weathersit         temp             atemp              hum        
##  Min.   :1.000   Min.   :0.05913   Min.   :0.07907   Min.   :0.0000  
##  1st Qu.:1.000   1st Qu.:0.33708   1st Qu.:0.33784   1st Qu.:0.5200  
##  Median :1.000   Median :0.49833   Median :0.48673   Median :0.6267  
##  Mean   :1.395   Mean   :0.49538   Mean   :0.47435   Mean   :0.6279  
##  3rd Qu.:2.000   3rd Qu.:0.65542   3rd Qu.:0.60860   3rd Qu.:0.7302  
##  Max.   :3.000   Max.   :0.86167   Max.   :0.84090   Max.   :0.9725  
##    windspeed           casual         registered        cnt      
##  Min.   :0.02239   Min.   :   2.0   Min.   :  20   Min.   :  22  
##  1st Qu.:0.13495   1st Qu.: 315.5   1st Qu.:2497   1st Qu.:3152  
##  Median :0.18097   Median : 713.0   Median :3662   Median :4548  
##  Mean   :0.19049   Mean   : 848.2   Mean   :3656   Mean   :4504  
##  3rd Qu.:0.23321   3rd Qu.:1096.0   3rd Qu.:4776   3rd Qu.:5956  
##  Max.   :0.50746   Max.   :3410.0   Max.   :6946   Max.   :8714
### Question 4 Response Variable

### 2 options: cnt, the total count of riders on a given day, and registered, the count of registered riders in a given day. 
total <- sum(day$cnt)
members <- sum(day$registered)
nonmem <- sum(day$casual)
members + nonmem
## [1] 3292679
nonmem/total
## [1] 0.1883017
### Because casual riders are nearly 20% of the total number of riders, it would make sense to use cnt as the dependent variable. The percentage of casual riders seems to be the same, whether on an overall basis or a daily basis, on average. 
total/731
## [1] 4504.349
nonmem/731
## [1] 848.1765
848/4504
## [1] 0.1882771
### Question 5 Linear Model

lin_model <- lm(formula = cnt ~  weathersit, data = day)
lin_model
## 
## Call:
## lm(formula = cnt ~ weathersit, data = day)
## 
## Coefficients:
## (Intercept)   weathersit  
##        5980        -1057
### Question 6 Scatterplot w/ line of best fit

plot(day$weathersit, day$cnt, pch = 16,  col = "red",  xlab = "Weather Conditions", ylab = "Number of Riders",
     main = "Ridership vs. Weather Conditions")
abline(lm(cnt ~ weathersit, data = day), lwd = 2)

summary(lin_model)
## 
## Call:
## lm(formula = cnt ~ weathersit, data = day)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4491.3 -1285.8   -45.1  1421.3  4496.9 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   5979.6      188.3   31.75   <2e-16 ***
## weathersit   -1057.3      125.7   -8.41   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1851 on 729 degrees of freedom
## Multiple R-squared:  0.08844,    Adjusted R-squared:  0.08719 
## F-statistic: 70.73 on 1 and 729 DF,  p-value: < 2.2e-16
### Question 7 Statistical significance of the model. 

### Yes, the model is statistically significant, given the t-value of the weathersit coefficient (-8.41) and its p-value (2e -16)

### Coefficients:
####            Estimate Std. Error t value Pr(>|t|)    
####(Intercept)   5979.6      188.3   31.75   <2e-16 ***
####weathersit   -1057.3      125.7   -8.41   <2e-16 ***
### Questions 8 and 9 Correlation coefficient and r squared
#### R-squared:  0.08844
#### Correlation coefficient is the square root of R-Squared or 0.2974
#### This means the weather conditions are weakly and negatively correlated w/ ridership; weather conditions explain about 8% of the variation in ridership in the bikeshare program. 

sqrt(.08844)
## [1] 0.2973886
### Question 10 Plot the residuals
res <- residuals(lin_model); res
##            1            2            3            4            5            6 
## -2880.059013 -3064.059013 -3573.346030 -3360.346030 -3322.346030 -3316.346030 
##            7            8            9           10           11           12 
## -2355.059013 -2906.059013 -4100.346030 -3601.346030 -2602.059013 -3760.346030 
##           13           14           15           16           17           18 
## -3516.346030 -3501.346030 -2617.059013 -3718.346030 -2865.059013 -3182.059013 
##           19           20           21           22           23           24 
## -2215.059013 -1938.059013 -3379.346030 -3941.346030 -3936.346030 -3506.346030 
##           25           26           27           28           29           30 
## -1880.059013 -2301.771996 -4491.346030 -2698.059013 -3824.346030 -3826.346030 
##           31           32           33           34           35           36 
## -2364.059013 -2505.059013 -2339.059013 -3372.346030 -2157.059013 -2860.059013 
##           37           38           39           40           41           42 
## -3299.346030 -3210.346030 -3392.346030 -2260.059013 -3384.346030 -3176.346030 
##           43           44           45           46           47           48 
## -3450.346030 -3333.346030 -3009.346030 -3107.346030 -2807.346030 -2447.346030 
##           49           50           51           52           53           54 
## -1995.346030 -3287.346030 -3110.346030 -2758.059013 -3472.346030 -3005.346030 
##           55           56           57           58           59           60 
## -2058.059013 -2404.059013 -2953.346030 -2520.346030 -2419.059013 -3071.346030 
##           61           62           63           64           65           66 
## -2788.346030 -3237.346030 -1921.059013 -1788.059013 -3260.059013 -3050.346030 
##           67           68           69           70           71           72 
## -2789.346030 -1974.059013 -2184.771996 -1888.059013 -2790.346030 -2505.346030 
##           73           74           75           76           77           78 
## -2876.346030 -1809.059013 -1673.059013 -2178.346030 -1683.346030 -1805.346030 
##           79           80           81           82           83           84 
## -2451.346030 -1788.059013 -2219.346030 -1744.059013 -2000.059013 -2712.346030 
##           85           86           87           88           89           90 
## -2426.346030 -2172.059013 -2894.346030 -2497.346030 -2329.059013 -1122.771996 
##           91           92           93           94           95           96 
## -1638.059013 -1613.059013 -1673.346030 -1807.346030 -2070.059013 -2114.346030 
##           97           98           99          100          101          102 
## -1781.346030 -2394.059013 -1410.059013  -970.059013  -517.059013 -1831.059013 
##          103          104          105          106          107          108 
## -1703.059013 -1655.346030 -1796.346030 -2012.771996 -1178.346030 -1493.346030 
##          109          110          111          112          113          114 
##  -661.059013  -978.346030  -733.346030 -2182.059013   170.940987   325.940987 
##          115          116          117          118          119          120 
##  -849.346030  -522.346030     6.940987   192.940987  -327.346030   389.653970 
##          121          122          123          124          125          126 
##  -514.059013   535.940987   585.940987 -1232.059013  -489.346030  -314.346030 
##          127          128          129          130          131          132 
##  -208.346030  -589.346030  -560.346030  -119.346030  -740.346030   -58.346030 
##          133          134          135          136          137          138 
##   239.940987  -456.059013   687.940987  -964.346030   257.940987   -10.059013 
##          139          140          141          142          143          144 
##   709.940987    -5.346030   882.653970  -262.346030   408.940987   626.940987 
##          145          146          147          148          149          150 
##    55.653970  -245.346030  -243.346030  -164.346030  -134.346030  -824.346030 
##          151          152          153          154          155          156 
##  -940.346030   108.940987    45.653970   389.653970   419.653970  1040.940987 
##          157          158          159          160          161          162 
##  -374.346030   -89.346030  -521.346030    49.940987  -336.346030    43.653970 
##          163          164          165          166          167          168 
##  -462.346030    97.653970   -31.346030   257.653970   -98.059013   -78.346030 
##          169          170          171          172          173          174 
##   196.653970   878.940987   144.940987   969.940987  -415.346030   924.940987 
##          175          176          177          178          179          180 
##    68.653970   279.653970   382.653970   842.940987  -274.346030   302.653970 
##          181          182          183          184          185          186 
##   592.653970   439.653970   196.653970   783.940987  2177.940987  -257.346030 
##          187          188          189          190          191          192 
##  -293.346030  -330.346030   174.940987   413.653970   -41.346030  -836.346030 
##          193          194          195          196          197          198 
##  -664.346030  -580.346030   161.653970   615.653970  1000.653970   379.653970 
##          199          200          201          202          203          204 
##  -464.346030  -381.346030  -590.346030   -81.059013 -1535.346030 -1637.346030 
##          205          206          207          208          209          210 
## -1316.346030 -1082.346030  -332.346030  -266.346030  -532.346030 -1076.346030 
##          211          212          213          214          215          216 
##  -447.346030  -620.346030  -656.346030   -77.346030  -291.059013   710.940987 
##          217          218          219          220          221          222 
##   -56.346030   428.940987 -1137.346030  -596.346030  -320.346030  -142.346030 
##          223          224          225          226          227          228 
##  -130.346030   -17.346030   284.940987   -45.059013  -584.346030  -197.346030 
##          229          230          231          232          233          234 
##  -228.346030 -1117.346030   287.940987   268.653970 -1049.346030  -164.346030 
##          235          236          237          238          239          240 
##   972.653970   207.653970  -323.059013  -261.346030 -2750.059013  -588.346030 
##          241          242          243          244          245          246 
##  -288.346030   281.653970   135.653970   192.653970   861.940987  -438.346030 
##          247          248          249          250          251          252 
##    17.653970  -514.059013   -97.771996  -811.771996  -965.771996  -321.059013 
##          253          254          255          256          257          258 
##   422.653970   123.653970  -209.346030  -159.346030  -137.346030  -206.059013 
##          259          260          261          262          263          264 
##   894.940987   645.940987  -648.346030   673.940987  -224.059013   486.940987 
##          265          266          267          268          269          270 
##   929.940987 -1470.059013  1557.940987  1144.940987   764.940987   254.940987 
##          271          272          273          274          275          276 
##    41.940987   -83.346030   279.653970 -1436.059013  -947.059013  -295.059013 
##          277          278          279          280          281          282 
##  -466.346030   -96.346030  -157.346030    62.653970   486.653970   588.653970 
##          283          284          285          286          287          288 
##   194.653970   697.940987  -391.771996  -952.059013  -221.059013   294.653970 
##          289          290          291          292          293          294 
##   118.653970  -352.346030   882.940987  -383.771996  -727.346030  -618.346030 
##          295          296          297          298          299          300 
##  -614.346030  -541.346030  -735.346030  -235.346030    28.940987 -1206.059013 
##          301          302          303          304          305          306 
##  -118.059013 -2180.771996 -1591.346030 -1253.346030  -854.346030  -736.346030 
##          307          308          309          310          311          312 
##  -948.346030   180.940987  -996.346030 -1273.346030  -887.346030  -717.346030 
##          313          314          315          316          317          318 
##  -813.346030  -932.059013 -1554.346030  -855.346030 -1205.346030  -436.346030 
##          319          320          321          322          323          324 
##   329.940987  -990.771996  -812.059013 -1530.346030 -1259.346030  -345.059013 
##          325          326          327          328          329          330 
##   -42.771996 -1200.771996 -1299.059013 -3427.346030 -2130.346030 -1854.346030 
##          331          332          333          334          335          336 
## -1851.346030 -1055.346030  -951.059013 -1309.346030 -1195.346030  -982.346030 
##          337          338          339          340          341          342 
## -1308.346030 -1437.346030   -54.059013  -213.771996 -2102.771996 -1600.346030 
##          343          344          345          346          347          348 
## -1302.346030 -1732.346030 -2179.346030 -1612.346030 -1399.346030  -125.059013 
##          349          350          351          352          353          354 
##  -156.059013  -288.059013 -1126.059013 -2491.346030 -1519.346030  -115.059013 
##          355          356          357          358          359          360 
## -1205.059013  -797.059013 -2713.346030 -3911.346030 -4168.346030 -3605.346030 
##          361          362          363          364          365          366 
## -2703.059013 -2620.346030 -2499.346030 -1923.346030 -2437.346030 -2628.346030 
##          367          368          369          370          371          372 
## -2971.346030 -2686.346030 -1497.059013 -1650.346030  -824.346030  -401.346030 
##          373          374          375          376          377          378 
## -1497.346030 -1489.059013 -1324.346030 -1688.059013   231.940987 -1708.346030 
##          379          380          381          382          383          384 
## -2429.346030 -2611.346030 -2624.346030  -930.059013 -1546.346030 -1630.346030 
##          385          386          387          388          389          390 
##  -702.059013 -2564.059013 -1888.059013 -1433.059013  -583.346030  -652.346030 
##          391          392          393          394          395          396 
##   209.940987  -409.059013  -899.346030 -1679.346030 -1298.346030  -413.346030 
##          397          398          399          400          401          402 
##  -343.346030  -104.059013  -771.346030 -1033.059013  -918.059013 -1138.346030 
##          403          404          405          406          407          408 
##  -547.346030 -1063.059013 -1092.346030   -34.059013  -638.771996 -3393.346030 
##          409          410          411          412          413          414 
## -1500.346030    56.940987  -753.346030  -860.059013  -768.346030  -604.346030 
##          415          416          417          418          419          420 
## -1176.059013 -1793.346030 -1145.346030  -149.346030   139.653970  -378.059013 
##          421          422          423          424          425          426 
## -2190.346030 -1533.346030  -600.346030  -559.346030 -2031.059013    67.653970 
##          427          428          429          430          431          432 
##  -671.059013   200.940987 -1499.346030 -1589.346030  -966.346030    -6.346030 
##          433          434          435          436          437          438 
##   459.653970   703.940987  -804.346030   -11.346030   375.653970   924.653970 
##          439          440          441          442          443          444 
##  1389.653970  1269.653970   512.940987  3970.940987  2026.940987  1230.653970 
##          445          446          447          448          449          450 
##  1170.653970  2364.940987  1948.653970  4496.940987  -493.059013  1130.940987 
##          451          452          453          454          455          456 
##   635.653970   179.653970   775.653970  1210.653970  1593.940987  2369.940987 
##          457          458          459          460          461          462 
##  2175.940987  1013.653970  1849.653970  1513.653970  1534.653970  1537.653970 
##          463          464          465          466          467          468 
##  1934.653970   246.653970   662.653970   995.653970   -60.346030   486.653970 
##          469          470          471          472          473          474 
##  1475.653970  2537.653970  2209.653970  1447.653970  1768.653970   501.940987 
##          475          476          477          478          479          480 
##  1642.653970  2367.653970  1701.653970 -1780.771996  -651.059013   710.653970 
##          481          482          483          484          485          486 
##  1273.653970  1160.940987  1310.653970   354.940987  1381.653970  1706.940987 
##          487          488          489          490          491          492 
##  1874.940987  1246.653970  2555.940987  1373.653970  3017.940987  2493.940987 
##          493          494          495          496          497          498 
##  2407.940987  1862.940987   851.940987  1649.653970  2107.653970  2506.653970 
##          499          500          501          502          503          504 
##  1195.653970 -1022.059013  1249.940987  2501.653970  2461.653970  2716.653970 
##          505          506          507          508          509          510 
##  3371.653970  2206.653970   493.940987  2207.940987  1394.940987  1847.653970 
##          511          512          513          514          515          516 
##  1811.653970  1613.653970  1668.653970  1120.653970   820.653970  2989.940987 
##          517          518          519          520          521          522 
##  2415.653970   261.940987  3197.653970  2718.653970  2075.653970  3135.940987 
##          523          524          525          526          527          528 
##  2132.653970  2571.653970  2813.653970  2575.653970  1675.653970  2798.940987 
##          529          530          531          532          533          534 
##  1106.940987  2498.653970  2440.653970  2742.653970  2779.653970  2055.653970 
##          535          536          537          538          539          540 
##  1233.940987  1902.653970  1288.653970   982.653970   900.653970  2535.653970 
##          541          542          543          544          545          546 
##  1968.653970  1856.653970  2519.653970  2412.653970  1956.653970   540.653970 
##          547          548          549          550          551          552 
##   764.653970   608.653970  1304.653970  1737.653970  2480.653970  1318.653970 
##          553          554          555          556          557          558 
##  1284.653970   -82.346030  -250.346030  2703.940987  2424.940987  2341.653970 
##          559          560          561          562          563          564 
##  2523.653970  3633.940987  3103.940987  1108.653970  1907.653970  1863.653970 
##          565          566          567          568          569          570 
##   790.653970  1668.653970  2004.940987  1651.228004  3544.940987  2043.653970 
##          571          572          573          574          575          576 
##  2669.653970  3250.653970  1938.653970  1981.653970  1762.653970  1674.653970 
##          577          578          579          580          581          582 
##  2182.653970  2293.653970  2657.653970  2338.653970  3309.940987  1901.653970 
##          583          584          585          586          587          588 
##   541.653970  3147.940987  3407.940987  3668.940987  2363.653970  1920.940987 
##          589          590          591          592          593          594 
##  2433.940987  1621.653970  1960.653970  1861.653970  2424.653970  2682.653970 
##          595          596          597          598          599          600 
##  2225.653970  2942.653970   683.940987  2664.940987  2083.653970  2452.653970 
##          601          602          603          604          605          606 
##  2842.653970  3716.940987  2187.940987  1389.940987  1994.653970  2117.653970 
##          607          608          609          610          611          612 
##  2774.653970  2790.653970  2427.653970  2274.940987  1944.940987  1111.653970 
##          613          614          615          616          617          618 
##  1941.653970  2189.653970  2337.940987  2581.653970  2110.940987  3304.653970 
##          619          620          621          622          623          624 
##  2602.653970  2844.653970  2947.653970  2881.653970  3086.653970  3791.653970 
##          625          626          627          628          629          630 
##  2410.653970  3003.940987   207.940987  2668.653970  2797.653970  3244.653970 
##          631          632          633          634          635          636 
##  3472.653970  2984.653970  2513.653970  2615.653970  2810.653970  3527.940987 
##          637          638          639          640          641          642 
##  3549.940987  3632.653970  1966.653970  2912.940987  1831.228004  3706.940987 
##          643          644          645          646          647          648 
##  3462.940987  3233.653970  3042.653970  -355.059013  1612.940987  2526.940987 
##          649          650          651          652          653          654 
##  2768.653970  2647.653970  2359.653970  2186.653970  1716.653970  2009.940987 
##          655          656          657          658          659          660 
##  2611.653970  2538.653970  3643.940987  1558.940987  3167.653970  1901.653970 
##          661          662          663          664          665          666 
##  2135.653970  2543.653970  2770.653970  3493.940987  3578.940987  3986.940987 
##          667          668          669          670          671          672 
##   593.940987 -2785.771996 -2769.059013  1700.940987  2120.940987   924.653970 
##          673          674          675          676          677          678 
##  1272.940987   184.653970   336.653970   763.653970  1169.940987   392.653970 
##          679          680          681          682          683          684 
##  1069.653970  1613.653970  1929.653970  1346.653970   228.940987   572.653970 
##          685          686          687          688          689          690 
##  1579.940987   775.653970   706.653970  -253.346030  1633.940987  1768.940987 
##          691          692          693          694          695          696 
##   223.653970 -2497.346030 -1012.346030 -2645.346030 -2498.346030   164.653970 
##          697          698          699          700          701          702 
##    93.940987   337.653970   400.653970   745.653970  1325.940987   783.940987 
##          703          704          705          706          707          708 
##  1311.653970  1683.653970   806.653970   452.653970  1142.940987  1716.940987 
##          709          710          711          712          713          714 
##  -637.059013  1304.940987  1635.940987  1453.940987   609.653970   688.653970 
##          715          716          717          718          719          720 
##   124.653970   -79.059013   719.940987   634.653970   344.653970   262.940987 
##          721          722          723          724          725          726 
##  -242.059013 -3173.346030 -3135.346030 -2945.059013 -2852.059013 -2366.771996 
##          727          728          729          730          731 
## -1751.059013  -770.059013 -2524.059013 -3126.346030 -1136.059013
plot(day$weathersit, res, ylab = 'Residual', xlab = 'Weather Conditions', pch = 16, 
     main = "Residuals for Ridership  vs. Weather Conditions")
abline(0, 0, lwd = 2)   

#### The residuals do appear to be randomly distributed, normally.  
### Question 11 Meeting the assumptions

#### The assumptions of the linear regression model are these: Linearity, Homoskedasticity, Independence, Normality. The results of this run appear to meet those assumptions.