# QUESTION call in the data.
# CG Qa # Read the data file bikeshare.csv into R
########## and name the object bikes. Use strings T
# QUESTION Data prep.
# CG Qa # Run str on the bikes data frame to see
########## the quantitative variables and to confirm
########## the strings T argument read in character
########## data as a factor.
# CG Qb # Run the following lines of code to make
########## month and weekdays, and holiday and work day
########## indicators factors.
bikes$mnth factorbikes$mnth
bikes$holiday factorbikes$holiday
bikes$weekday factorbikes$weekday
bikes$workingday factorbikes$workingday
# CG Qc # Run str on the bikes data frame to see that
########## the Qb code made these variables factors.
# QUESTION Fit a regression model and inspect results
# CG Qa # Fit a regression model called fit to model ride
########## count by temperature, humidity, windspeed,
########## weathersit, holiday indicator, and month.
# CG Qb # Use the summary function to print the results of
########## the regression.
# CG Qc # Use the coef function to print the
########## coefficient for September. Use the same
########## code you learned in previous regressions HWs
# CG Qd # Choose the correct interpretation.
########## A: As month increases by expect count to decrease by
########## B: As month increases by expect count to increase by
########## C: We expect count in September to be lower than for January.
########## D: We expect count in September to be higher than for January.
########## Use paste with the letter choice in quotes.
# CG Qe # Calculate the Rsquared using the formula from
########## previous regression HWs with deviance and null.deviance
# CG Qf # Find the autocorrelation at lag for the residuals
########## from the regression. Use the code below.
acffit$residuals, plotF
# CG Qg # Based on the results from Qf is there autcorrelation
########## at lag Type pasteY or pasteN
# QUESTION Fit an AR model to account for autcorrelation.
# CG Qa # Run the provided code to add lagged count
########## and check that it worked as expected.
bikes$lag cNA bikes$cnt:nrowbikes #create lagged variable
headbikesccnt"lag" # confirm it worked as planned
# CG Qb # Fit a regression using the variables from Qa
########## with the addition of the lagged variable.
########## Call your fitted model arfit.
# CG Qc # Find the Rsquared using the same code
########## structure from previous HWs and lecture.
# CG Qd # Use similar code to Qf to print the
########## autocorrelation at lag for the residuals
########## from your AR regression.
# CG Qe # Use the coef function to print the
########## coefficient for the lag term.
# CG Qf # Type pasteY is the autocorrelation at
########## lag is essentially Otherwise, use pasteN
# CG Qg # The coefficient for the lag term indicates
########## A: a random walk
########## B: stationary, meanreverting
########## C: diverging
########## Use paste with the selected letter in quotes.