Question: * * THE PROGRAMMING LANGUAGE IS IN R , RSTUDIOS, and JUPYTER. Please don't use pandas or Python. 7 . 8 LAB: Creating simple linear
THE PROGRAMMING LANGUAGE IS IN RRSTUDIOS, and JUPYTER. Please don't use pandas or Python.
LAB: Creating simple linear regression models
The nbaalleloslr dataset contains information on NBA games between and The columns report the points made
by one team, the Elo rating of that team coming into the game, the Elo rating of the team after the game, and the points made by the
opposing team. The Elo score measures the relative skill of teams in a league.
Load the dataset into a data frame.
Create a new column y in the data frame that is the difference between the points made by the two teams.
Use the lm function to perform a simple linear regression using y as the output feature and eloi as the input feature.
Print the intercept and slope of the linear regression model.
Compute the proportion of variation explained by the linear regression.
Ex: If the Elo rating of the team after the game, elon is used instead of eloi the output is:
"The intercept of the linear regression line is
"The slope of the linear regression line is
"The proportion of variation explained by the linear regression model is
xxzqy
Start of code
Read in nbaalleloslrcsv
nba # Your code here
Create a new column in the data frame that is the difference between pts and opppts
nba$y # Your code here
Fit a least squares regression model on y and eloi
SLRModel # Your code here
Print the intercept
intercept # Your code here
printpasteThe intercept of the linear regression line is formatroundintercept
Print the slope
slope # Your code here
printpasteThe slope of the linear regression line is formatroundslope
Compute the proportion of variation explained by the linear regression
rSquare # Your code here
printpasteThe proportion of variation explained by the linear regression model is formatroundrSquare
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
