Question
# CG Q0 # Read the data file bikeshare.csv into R and name the object bikes. ####### As usual, don't forget the strings = T
# CG Q0 # Read the data file bikeshare.csv into R and name the object bikes.
####### As usual, don't forget the strings = T argument.
# CG Q1 # Run str() on the bikes data frame to see that
###### there are quantitative variables and to confirm that the
###### strings = T argument did in fact allow character data
###### to be read in a a factor.
# Question 2 - Simple linear model.
# CG Q2a # Build a linear regression model that has
####### count as the response and
####### the weather situation variable as predictor.
####### Name your fitted model simplefit.
# CG Q2b # Use the summary() function on simplefit
###### to access the results of the regression.
# CG Q2c # Print the coefficient for the wet weather situation.
####### Use coef(simplefit) followed by the name of that
####### coefficient in quotes inside square brackets.
####### For example, coef(simplefit)["weathersitcloudy"] prints
####### the coefficient for the cloudy weather situation.
# CG Q2d # Using the regression output, determine how the ride count
####### for wet days compares to the ride count on clear days.
####### If it's higher on wet days, type paste("higher")
####### If it's lower on wet days, type paste("lower")
# CG Q2e # Find the R-squared for the regression.
####### In your calculation, use simplefit$deviance and
####### simplefit$null.deviance and not the numbers printed
####### in the summary output for these.
# Question 3 - Linear model with multiple predictors.
# CG Q3a # Run a linear regression using ride counts as the response
###### modeled by the weather variables weathersit, temp, hum, and windspeed.
###### Use an additive model (don't model interactions or anything fancy).
###### Name your fitted model ridefit.
# CG Q3b # Use summary() on your fitted model to print the results.
# CG Q3c # How does expected ride count change with an increase in temperature?
####### Print the coefficient for temp in the ridefit model
####### using the same strategy used in Q2c.
# CG Q3d # Based on the temp coefficient, do we expect ride count to increase
####### or decrease by 156 rides with an increase in temperature?
####### If ride count is expected to increase with temperature,
####### type paste("increase"). Otherwise paste("decrease").
# CG Q3e # Find the R-squared for the ridefit regression.
####### In your calculation, use ridefit$deviance and
####### ridefit$null.deviance and not the numbers printed
####### in the summary output for these.
# Question 4 - log-linear model.
# CG Q4a # Now, run a linear regression using log ride counts as the response
###### modeled by the weather variables weathersit, temp, hum, and windspeed.
###### Use these same predictors as ridefit and name this new model logridefit
# CG Q4b # Use summary() on your fitted model to print the results.
# CG Q4c # How does expected log ride count change with an increase in temperature?
####### Print the coefficient for temp in the logridefit model
####### using the same strategy used in Q2c.
# CG Q4d # Based on the temp coefficient from log ridefit,
####### do we expect ride count to increase
####### or decrease with an increase in temperature?
####### If log ride count is expected to increae with temperature,
####### type paste("increase"), otherwise paste("decrease").
# CG Q4e # Now print the multiplicative effect of temperature
####### on expected ride count by wrapping the line of code
####### from Q4c in the exp() function.
# CG Q4f # Find the R-squared for the logridefit regression.
####### In your calculation, use logridefit$deviance and
####### logridefit$null.deviance and not the numbers printed
####### in the summary output for these.
# Question 5 - log-log model
# CG Q5a # Now, run a linear regression using log ride counts as the response
###### modeled by the weather variables weathersit, log(temp), hum, and windspeed.
###### Note the log() on the temp predictor.
###### Name your model loglogfit.
# CG Q5b # Use summary() on your fitted model to print the results.
# CG Q5c # How does expected percent ride count change with a
####### 1% increase in temperature?
####### Print the coefficient for log(temp) in the loglogfit model
####### using the same strategy used in Q2c.
# CG Q5d # Based on the log(temp) coefficient from loglogfit,
####### do we expect a percent increase or decrease in
####### ride count for each 1% increase in temperature?
####### If a percent increase is expected, type paste("increase")
####### otherwise paste("decrease")
# CG Q5e # Find the R-squared for the loglogfit regression.
####### In your calculation, use loglogfit$deviance and
####### loglogfit$null.deviance and not the numbers printed
####### in the summary output for these.
# Question 6 - Let's practice making predictions of the response variable.
# CG Q6a # We'll make predictions using all 3 competing models for
####### a wet day that is 25 degrees, has 50% humidity and windspeed of 5.
####### Make a data frame of these values and call it newdata.
# CG Q6b # Now use ridefit model to predict ride count using
####### the predict() function with your newdata object.
# CG Q6c # Now use the logridefit model to predict log ride count using
####### the predict() function with your newdata object.
# CG Q6d # To put the prediction of the log ride count back onto the raw
####### ride count scale, wrap the line of code from Q6c in the exp()
####### function to "undo" the log transformation.
# CG Q6e # use the loglogfit model to predict log ride count using
####### the predict() function with your newdata object.
# CG Q6f # To put the prediction of the log ride count back onto the raw
####### ride count scale, wrap the line of code from Q6e in the exp()
####### function to "undo" the log transformation.
answer all of these
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started