The daily total of bike counts was conducted monthly on the Brooklyn Bridge, Manhattan Bridge, Williamsburg Bridge, and Queensboro Bridge. To keep count of cyclists entering and leaving Queens, Manhattan, and Brooklyn via the East River Bridges. The Traffic Information Management System (TIMS) collects the count data. Each record represents the total number of cyclists per 24 hours at Queensboro Bridge. The data set has a total of 31 observations.
Variables in data set: Day: Character Variable HighTemp: Numerical Variable LowTemp: Numerical Variable Precipitation: Numerical Variable QueensboroBridge: Numerical Response Variable Total: Numerical Variable
What is the relationship between temperature, precipitation and the total number of cyclists crossing the East River via the Queensboro Bridge?
The variables HighTemp and LowTemp are added together and average to create a new variable called Temp. The first few observations of the data set are listed below.
## Warning in data(Weber): data set 'Weber' not found
| Date | Day | HighTemp | LowTemp | Precipitation | QueensboroBridge | Total | Temp |
|---|---|---|---|---|---|---|---|
| 10/1 | Sunday | 66.9 | 50.0 | 0 | 4092 | 15975 | 58.45 |
| 10/2 | Monday | 72.0 | 52.0 | 0 | 5722 | 23784 | 62.00 |
| 10/3 | Tuesday | 70.0 | 57.0 | 0 | 6363 | 25280 | 63.50 |
| 10/4 | Wednesday | 75.0 | 55.9 | 0 | 6238 | 25477 | 65.45 |
| 10/5 | Thursday | 82.0 | 64.9 | 0 | 5998 | 23942 | 73.45 |
| 10/6 | Friday | 81.0 | 69.1 | 0 | 5675 | 22197 | 75.05 |
This code is fitting a Poisson regression model to the counts of cyclists across Queensboro Bridge using temperature, precipitation, and day of the week as predictors. The baseline level is Friday.
The model estimates the coefficients for each predictor, as well as the intercept. The coefficients indicate the change in the log count of cyclists for a one-unit increase in the predictor while holding all other predictors constant. For example, a one-unit increase in low temperature is associated with a decrease in log count of -0.0188061.
All of the coefficients, except for Thursday, are statistically significant at the 0.05 level.
| Estimate | Std. Error | z value | Pr(>|z|) | |
|---|---|---|---|---|
| (Intercept) | 8.4587825 | 0.0243559 | 347.2984819 | 0.0000000 |
| Temp | 0.0023537 | 0.0003677 | 6.4009876 | 0.0000000 |
| Precipitation | -0.6713250 | 0.0141378 | -47.4842775 | 0.0000000 |
| DayMonday | -0.1358858 | 0.0096168 | -14.1300957 | 0.0000000 |
| DaySaturday | -0.2307976 | 0.0102599 | -22.4951288 | 0.0000000 |
| DaySunday | -0.3339165 | 0.0107582 | -31.0383469 | 0.0000000 |
| DayThursday | 0.0073136 | 0.0095759 | 0.7637429 | 0.4450205 |
| DayTuesday | -0.0362627 | 0.0092643 | -3.9142264 | 0.0000907 |
| DayWednesday | 0.0742529 | 0.0094056 | 7.8945354 | 0.0000000 |
The Poisson regression model is used to estimate the relationship between the number of bikers crossing the Queensboro Bridge and temperature, precipitation, and day of the week. The model uses the log of the total number of observations as an offset variable. The output shows that temperature is not a significant predictor of bike counts, as its p-value is greater than the alpha level of 0.05. However, precipitation is a significant predictor, as its p-value is much smaller than the alpha level.
Overall, the Poisson regression model indicates that precipitation is a significant predictor of bike counts on the Queensboro Bridge, while temperature and day of the week are not significant predictors.
| Estimate | Std. Error | z value | Pr(>|z|) | |
|---|---|---|---|---|
| (Intercept) | -1.3781324 | 0.0250406 | -55.0358698 | 0.0000000 |
| Temp | 0.0002365 | 0.0003780 | 0.6257540 | 0.5314763 |
| Precipitation | 0.1135314 | 0.0106298 | 10.6805018 | 0.0000000 |
| DayMonday | 0.0017291 | 0.0095515 | 0.1810262 | 0.8563470 |
| DaySaturday | 0.0021215 | 0.0102658 | 0.2066581 | 0.8362769 |
| DaySunday | -0.0168108 | 0.0108072 | -1.5555146 | 0.1198236 |
| DayThursday | 0.0012905 | 0.0095709 | 0.1348342 | 0.8927429 |
| DayTuesday | -0.0092861 | 0.0092593 | -1.0029049 | 0.3159068 |
| DayWednesday | -0.0116545 | 0.0094028 | -1.2394654 | 0.2151732 |
This code defines different rates of people crossing Queensboro Bridge for each day of the week.The graphs are separated into two parts, one showing the days of the week with precipitation, and one showing the days of the week without precipitation. While only days of the week are visible on the graph, all days are plotted. the reason behind this is because the data points are so similar that the lines overlap each other. Using the visible lines as an example, in both graphs Monday would have the highest rate of change out of all the days, followed by Friday, and then Tuesday. Additionally, there seems to be a higher rate of change on days where there is precipitation compared to days where there is not.
This is a Poisson regression model that examines the relationship between the counts of cyclists crossing the Queensboro Bridge and various predictor variables. The predictor variables include weather factors such as low temperature, high temperature, precipitation, and the day of the week.
The estimated coefficients for the predictor variables represent the expected change in the log count of cyclists crossing the bridge for a one-unit increase in the corresponding predictor variable, holding all other variables constant. For example, a one-unit increase in low temperature is associated with a decrease of 0.0188 in the log count of cyclists crossing the bridge, on average, holding all other variables constant.
Overall, this model suggests that weather factors and the day of the week are significant predictors of the number of cyclists crossing the Queensboro Bridge. For example, higher precipitation is associated with a lower number of cyclists crossing the bridge, while DaySaturday and DaySunday are associated with a lower number of cyclists compared to other days of the week. The model can be used to make predictions about the expected number of cyclists crossing the bridge based on the weather forecast and the day of the week.
| Estimate | Std. Error | z value | Pr(>|z|) | |
|---|---|---|---|---|
| (Intercept) | 8.4587825 | 0.0243559 | 347.2984819 | 0.0000000 |
| Temp | 0.0023537 | 0.0003677 | 6.4009876 | 0.0000000 |
| Precipitation | -0.6713250 | 0.0141378 | -47.4842775 | 0.0000000 |
| DayMonday | -0.1358858 | 0.0096168 | -14.1300957 | 0.0000000 |
| DaySaturday | -0.2307976 | 0.0102599 | -22.4951288 | 0.0000000 |
| DaySunday | -0.3339165 | 0.0107582 | -31.0383469 | 0.0000000 |
| DayThursday | 0.0073136 | 0.0095759 | 0.7637429 | 0.4450205 |
| DayTuesday | -0.0362627 | 0.0092643 | -3.9142264 | 0.0000907 |
| DayWednesday | 0.0742529 | 0.0094056 | 7.8945354 | 0.0000000 |
The inferential table about the regression coefficients indicates that all variables except for Thursday are significant. In this case all variables other than Thursday have a p-value lower than 0.05, while Thursday’s p-value is 0.445, well above the cutoff point.
The Intercept coefficient (8.459) represents the expected number of bikers when all predictors are equal to zero.
Temperature has a positive coefficient (0.002354), indicating that the number of bikers is expected to increase as temperature increases while Precipitation has a negative coefficient (-0.6713), indicating that the number of bikers is expected to decrease as precipitation increases.
For day of the Week, Monday, Saturday, and Sunday have negative coefficients, indicating that the number of bikers is expected to be lower on these days. Tuesday has a negative coefficient as well, but with a smaller magnitude. Thursday has a positive coefficient, but also a p-value greater than 0.05, making it not significant.
| Estimate | Std. Error | z value | Pr(>|z|) | |
|---|---|---|---|---|
| (Intercept) | 8.459 | 0.02436 | 347.3 | 0 |
| Temp | 0.002354 | 0.0003677 | 6.401 | 1.544e-10 |
| Precipitation | -0.6713 | 0.01414 | -47.48 | 0 |
| DayMonday | -0.1359 | 0.009617 | -14.13 | 2.478e-45 |
| DaySaturday | -0.2308 | 0.01026 | -22.5 | 4.632e-112 |
| DaySunday | -0.3339 | 0.01076 | -31.04 | 1.639e-211 |
| DayThursday | 0.007314 | 0.009576 | 0.7637 | 0.445 |
| DayTuesday | -0.03626 | 0.009264 | -3.914 | 9.069e-05 |
| DayWednesday | 0.07425 | 0.009406 | 7.895 | 2.914e-15 |
This table is similar to the above table, but this includes an offset parameter which is used to specify the logarithm of the total number of observations as an offset variable.
This time, all of the variables except for Precipitation are insignificant at the alpha = 0.05 level.
Since the intercept is negative this indicates that there is a decrease in the number of bikers crossing the bridge when temperature and precipitation are held constant. As for the rest of the variables, most of them are not significant, while Precipitation is the only significant variable.
| Estimate | Std. Error | z value | Pr(>|z|) | |
|---|---|---|---|---|
| (Intercept) | -1.378 | 0.02504 | -55.04 | 0 |
| Temp | 0.0002365 | 0.000378 | 0.6258 | 0.5315 |
| Precipitation | 0.1135 | 0.01063 | 10.68 | 1.256e-26 |
| DayMonday | 0.001729 | 0.009551 | 0.181 | 0.8563 |
| DaySaturday | 0.002122 | 0.01027 | 0.2067 | 0.8363 |
| DaySunday | -0.01681 | 0.01081 | -1.556 | 0.1198 |
| DayThursday | 0.00129 | 0.009571 | 0.1348 | 0.8927 |
| DayTuesday | -0.009286 | 0.009259 | -1.003 | 0.3159 |
| DayWednesday | -0.01165 | 0.009403 | -1.239 | 0.2152 |
The above two Poison models assume that there is no dispersion issue in the model. The quasi-Poisson through glm() returns the dispersion coefficient.
The dispersion present in this model is 0, so this model will be used. The intercept represents the baseline log-rate of baseline group Friday. The intercept -1.37 is the difference of the log-rates between baseline Friday and Temp at any given Day.
| Estimate | Std. Error | t value | Pr(>|t|) | |
|---|---|---|---|---|
| (Intercept) | -1.37 | 0.07799 | -17.57 | 1.967e-14 |
| Temp | 0.0001112 | 0.001177 | 0.09445 | 0.9256 |
| cate.precipY | 0.04091 | 0.02071 | 1.975 | 0.06094 |
| DayMonday | -0.01052 | 0.03124 | -0.3366 | 0.7396 |
| DaySaturday | -0.004502 | 0.03224 | -0.1396 | 0.8902 |
| DaySunday | -0.01095 | 0.03399 | -0.3222 | 0.7503 |
| DayThursday | -0.005935 | 0.03012 | -0.197 | 0.8456 |
| DayTuesday | -0.01138 | 0.02888 | -0.3941 | 0.6973 |
| DayWednesday | -0.01937 | 0.02963 | -0.6537 | 0.5201 |
| Dispersion |
|---|
| 0 |
The inferential tables of the Poisson regression models in the previous sections give numerical information about the potential discrepancy across the days of the week with Temp and Precipitation. A graph can be created to visualize the relationship between Queensboro Bridge cyclist rate’s and Temperature and precipitation. This graph and its interpretation is the same as previously shown above.
This code fits a Poisson regression model to predict the number of bikers crossing the Queensboro Bridge based on temperature, categorical precipitation (Y/N), and the day of the week, while including the natural logarithm of the total number of observations as an offset.
The intercept is positive, but it is not significant at the alpha = 0.05 level, indicating that when all other predictors are held constant, the expected count of bikers is close to zero. The temperature coefficient is positive and significant (p = 0.025), indicating that as temperature increases, the expected count of bikers also increases. The categorical precipitation variable is negative and significant (p = 0.028), indicating that the expected count of bikers is lower when there is precipitation. Among the day of the week variables, only DaySaturday and DaySunday have significant coefficients. The coefficient for DaySaturday is negative (p = 0.004), indicating that the expected count of bikers is lower on Saturdays than on other days of the week. The coefficient for DaySunday is even more negative (p < 0.001), indicating that the expected count of bikers is lower on Sundays than on other days of the week.
Finally, the coefficient for the offset variable (log(Total)) is positive and highly significant (p < 0.001), indicating that the expected count of bikers increases as the total number of observations increases.
Overall, the Poisson regression analysis provides some insight into the factors influencing bike traffic on the Queensboro Bridge, but additional research may be necessary to fully understand the relationships between these variables.
| Estimate | Std. Error | z value | Pr(>|z|) | |
|---|---|---|---|---|
| (Intercept) | 0.1210751 | 0.1353725 | 0.8943846 | 0.3711161 |
| Temp | 0.0008582 | 0.0003828 | 2.2417014 | 0.0249807 |
| cate.precipY | -0.0189115 | 0.0086146 | -2.1952938 | 0.0281425 |
| DayMonday | -0.0053204 | 0.0100570 | -0.5290197 | 0.5967918 |
| DaySaturday | -0.0306138 | 0.0106092 | -2.8855952 | 0.0039067 |
| DaySunday | -0.0560207 | 0.0116747 | -4.7984879 | 0.0000016 |
| DayThursday | 0.0070039 | 0.0097484 | 0.7184627 | 0.4724721 |
| DayTuesday | -0.0062609 | 0.0092989 | -0.6732888 | 0.5007636 |
| DayWednesday | 0.0058308 | 0.0097856 | 0.5958502 | 0.5512753 |
| log(Total) | 0.8456878 | 0.0137647 | 61.4389779 | 0.0000000 |