Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# QUESTION 0 - - - call in the data. # CG Q 0 a # Read the data file bikeshare.csv into R ########## and

# 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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Accounting Tools For Business Decision Making

Authors: Paul D. Kimmel

3rd Edition

0470377852, 978-0470377857

More Books

Students also viewed these Accounting questions

Question

What is cultural tourism and why is it growing?

Answered: 1 week ago

Question

What is the major competition for your organization?

Answered: 1 week ago

Question

How accurate is this existing information?

Answered: 1 week ago