Skip to main content

Solution Manual For Modern Business Analytics, 1st Edition by Matt Taddy and Leslie Hendrix and Matt

Page 1

Solution Manual For Modern Business Analytics, 1st Edition Matt Taddy and Leslie Hendrix and Matthew Harding Chapter 1-9

Chapter 1 Regression Problem 1.1 For this problem set, we will use 13,103 observations of hourly counts from 2011 to 2012 for bike rides (rentals) from the Capital Bikeshare system in Washington DC. The data are recorded for hours after 6am every day. (We omit earlier hours for convenience since they often include zero ride counts.) This dataset is adapted from data originally compiled by Fanaee and Gama in ‗Event labeling combining ensemble detectors and background knowledge‘ (2013). This data can be used for modeling system usage (ride counts). Such usage modeling is a key input for operational planning. bikeshare.csv contains:

         

dteday: date mnth: month (1 to 12) holiday: whether day is holiday or not weekday: day of the week, counting from 0:sunday. workingday: if day is either weekend or holiday is 0, otherwise is 1. weathersit: broad overall weather summary (clear, cloudy, wet) temp: Temperature, measured in Celsius hum: Humidity % windspeed: Wind speed, measured in km per hour cnt: count of total bike rentals that day

<bikeshare.csv> <bikeshareReadme.txt> Read the bikeshare.csv data into R. Plot the marginal distribution for the count of bike rentals and the conditional count distribution given the broad weather situation (weathersit).

a-1. Use a histogram to plot the marginal distribution for the count of bike rentals. What is the shape of the distribution? a. skewed left b. fairly symmetric

© McGraw Hill LLC. All rights reserved. No reproduction or distribution without the prior written consent of McGraw Hill LLC.


c. skewed right

Explanation/Solution The following code draws a histogram plotting the marginal distribution for the count of bike rentals: biketab <- read.csv("bikeshare.csv", strings=T) hist(biketab$cnt, xlab="daily ride count", freq=FALSE, main="")

a-2. If you haven‘t already, read the bikeshare.csv data into R and make sure to use the strings=T argument in the read.csv function Create side-by-side boxplots to show the conditional count distribution, given the broad weather situation (weathersit). What does the side-by-side boxplot look like? (The top image is correct.)

a.

© McGraw Hill LLC. All rights reserved. No reproduction or distribution without the prior written consent of McGraw Hill LLC.


b.

c. Explanation/Solution The following code draws side-by-side boxplots showing the conditional count distribution, given the broad weather situation: biketab <- read.csv("bikeshare.csv", strings=T) boxplot(cnt ~ weathersit, data = biketab, xlab="weather situation", ylab="daily ride count")

Problem 1.2 Read the bikeshare.csv data into R and make sure to use the strings=T argument in the read.csv function. Fit a regression for ride count as a function of the weather situation variable to answer the following questions. a. On wet days, is the expected ride count higher or lower compared to clear days?

© McGraw Hill LLC. All rights reserved. No reproduction or distribution without the prior written consent of McGraw Hill LLC.


On wet days, the expected ride count is lower by 3,073.5 +/-0.1

b. What is the SSE? 2467890819 (+/-1)

c. What is the R2? R2=0.1 (+/-0.01)

d. What is the estimate of the standard deviation of the residual errors? 1841 (+/-1) Explanation/Solution biketab <- read.csv("bikeshare.csv", strings=T) #read data in and make categorical variables factors using strings=T argument class(biketab$weathersit) #check to be sure weathersit is a factor [1] "factor"

If the result of the above says "character" instead of "factor" then use the code below to make weathersit a factor: biketab$weathersit <- factor(biketab$weathersit) levels(biketab$weathersit) [1] "clear" "cloudy" "wet"

Next, use GLM to regress the counts onto the weather situation variable. wsfit <- glm(cnt ~ weathersit, data=biketab) summary(wsfit) Call: glm(formula = cnt ~ weathersit, data = biketab) Deviance Residuals: Min 1Q −4445.8 −1254.8

Median −14.8

3Q 1400.7

Max 4326.1

Coefficients: Estimate Standard Error t value Pr(>|t|) (Intercept) 4876.79 85.57 56.994 < 2e-16 *** weathersitcloudy -840.92 145.07 -5.797 1.01e-08 ***

© McGraw Hill LLC. All rights reserved. No reproduction or distribution without the prior written consent of McGraw Hill LLC.


weathersitwet

Estimate Standard Error t value Pr(>|t|) -3073.50 410.79 -7.482 2.12e-13 ***

Significance codes:

0 „***‟ 0.001 „**‟ 0.01 „*‟ 0.05 „.‟ 0.1 „ ‟ 1

(Dispersion parameter for gaussian family taken to be 3389960) Null deviance: 2739535392 on 730 degrees of freedom Residual deviance: 2467890819 on 728 degrees of freedom AIC: 13071 Number of Fisher Scoring iterations: 2

a. We see that `weather situation ―clear‖ is the reference level, with an expected ride count of 4877 rides per hour. Wet days have an expected 3073.5 fewer rides per hour, so the expected ride count is lower. b. From the summary.glm output, the SSE is 2467890819. c. 1 - wsfit$deviance/wsfit$null.deviance d. The residual error variance is 3389960 (the ―dispersion parameter‖) so the standard error is around 1841. sqrt(wsfit$deviance/wsfit$df.residual)

Problem 1.3 If you haven‘t already, read the bikeshare.csv data into R and make sure to use the strings=T argument in the read.csv function. Run a linear regression using ride counts as the response and model the response from the weather variables weathersit, temp, hum, and windspeed.

For each 10-degree increase in the temperature, we expect ride count to increase/decrease by about 1560 (+/-1) Explanation/Solution biketab <- read.csv("bikeshare.csv", strings=T) #read data in and make categorical variables factors using strings=T argument

ridefit <- glm(cnt ~ weathersit + temp + hum + windspeed, data=biketab) coef(ridefit) (Intercept) weathersitcloudy

weathersitwet

3434.91953

-287.24322

-1824.47164

temp

hum

windspeed

© McGraw Hill LLC. All rights reserved. No reproduction or distribution without the prior written consent of McGraw Hill LLC.


Turn static files into dynamic content formats.

Create a flipbook
Solution Manual For Modern Business Analytics, 1st Edition by Matt Taddy and Leslie Hendrix and Matt by AnswerDone - Issuu