# QUESTION 0--- call in the data. # CG Q0a # Read...

70.2K

Verified Solution

Question

Accounting

# QUESTION 0--- call in the data.
# CG Q0a # Read the data file bikeshare.csv into R
########## and name the object bikes. Use strings = T.
# QUESTION 1--- Data prep.
# CG Q1a # 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 Q1b # Run the following lines of code to make
########## month and weekdays, and holiday and work day
########## indicators factors.
bikes$mnth <- factor(bikes$mnth)
bikes$holiday <- factor(bikes$holiday)
bikes$weekday <- factor(bikes$weekday)
bikes$workingday <- factor(bikes$workingday)
# CG Q1c # Run str() on the bikes data frame to see that
########## the Q1b code made these 4 variables factors.
# QUESTION 2--- Fit a regression model and inspect results
# CG Q2a # Fit a regression model called fit to model ride
########## count by temperature, humidity, windspeed,
########## weathersit, holiday indicator, and month.
# CG Q2b # Use the summary() function to print the results of
########## the regression.
# CG Q2c # Use the coef() function to print the
########## coefficient for September. Use the same
########## code you learned in previous regressions HWs.
# CG Q2d # Choose the correct interpretation.
########## A: As month increases by 1, expect count to decrease by 1265.
########## B: As month increases by 1, expect count to increase by 1265.
########## C: We expect count in September to be 1265 lower than for January.
########## D: We expect count in September to be 1265 higher than for January.
########## Use paste() with the letter choice in quotes.
# CG Q2e # Calculate the R-squared using the formula from
########## previous regression HWs (with deviance and null.deviance).
# CG Q2f # Find the autocorrelation at lag-1 for the residuals
########## from the regression. Use the code below.
acf(fit$residuals, plot=F)[1]
# CG Q2g # Based on the results from Q2f, is there autcorrelation
########## at lag-1? Type paste("Y") or paste("N").
# QUESTION 3--- Fit an AR1 model to account for autcorrelation.
# CG Q3a # Run the provided code to add lagged count
########## and check that it worked as expected.
bikes$lag <- c(NA, bikes$cnt[2:nrow(bikes)-1]) #create lagged variable
head(bikes[,c("cnt","lag")]) # confirm it worked as planned
# CG Q3b # Fit a regression using the variables from Q2a
########## with the addition of the lagged variable.
########## Call your fitted model ar1fit.
# CG Q3c # Find the R-squared using the same code
########## structure from previous HWs and lecture.
# CG Q3d # Use similar code to Q2f to print the
########## autocorrelation at lag 1 for the residuals
########## from your AR regression.
# CG Q3e # Use the coef() function to print the
########## coefficient for the lag-1 term.
# CG Q3f # Type paste("Y") is the autocorrelation at
########## lag-1 is essentially 0. Otherwise, use paste("N")
# CG Q3g # The coefficient for the lag-1 term indicates
########## A: a random walk
########## B: stationary, mean-reverting
########## C: diverging
########## Use paste() with the selected letter in quotes.

Answer & Explanation Solved by verified expert
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students