SellingPrice | Age | Miles |
13558 | 5 | 61476 |
13764 | 8 | 54397 |
22905 | 1 | 8281 |
15280 | 1 | 24871 |
16430 | 2 | 22139 |
16645 | 2 | 23741 |
16992 | 2 | 47426 |
18444 | 2 | 16865 |
18849 | 3 | 35394 |
19877 | 3 | 29634 |
11812 | 6 | 55785 |
14901 | 1 | 46212 |
15903 | 3 | 37007 |
16502 | 5 | 45473 |
9415 | 10 | 86861 |
12931 | 6 | 77208 |
15731 | 9 | 59603 |
10536 | 7 | 93212 |
8907 | 8 | 48263 |
11996 | 6 | 42434 |
A) Determine the sample regression equation that enables us to predict the price of a sedan on the basis of its age and mileage. (Negative values should be indicated by a minus sign. Round your answers to 2 decimal places.) [If you are using R to obtain the output, then first enter the following command at the prompt: options(scipen=10). This will ensure that the output is not in scientific notation.]
B) Use the predict() function in R or use the regression output to predict the selling price of a six-year-old sedan with 63,000 miles. (Round answer to 2 decimal places.)
Solution:
A)
R Code
df<-read.csv(file.choose()) # Choose the csv file which
contains the above data
reg_model<-lm(df$SellingPrice~df$Age+df$Miles, data = df) #
Regression Line
reg_model
Output:
So the regression line becomes
B)
R code to predict the Sell Price
predict(reg_model,data.frame(Age=6,Miles=63000)) # Predict Sell price for age =6 and miles=63000
Therefore, the predicted sell Price for the 6-year-old sedan with 63,000 miles is 13089.10
Complete R code
df<-read.csv(file.choose())
attach(df)
reg_model<-lm(SellingPrice~Age+Miles, data = df)
reg_model
predict(reg_model,data.frame(Age=6,Miles=63000))
Get Answers For Free
Most questions answered within 1 hours.