Question

In: Statistics and Probability

Use R statictical software. Load the ISLR package to get the Auto data set. Fit below...

Use R statictical software. Load the ISLR package to get the Auto data set. Fit below non-linear models to the Auto data set. We will treat horsepower as the predictor and mpg as the response.
• Fit the cubic spline with 3 knots (25th percentile, 50th percentile, and 75th percentile of horsepower)
• Fit the natural spline with 3 knots (25th percentile, 50th percentile, and 75th percentile of horsepower)
• Fit the smoothing spline by choosing optimal lambda with cross-validation. (Hint: cv = TRUE can be used inside smooth.spline() function to choose optimal lambda with cross-validation.)
• Fit the local regression with span = 0.75.
Also, plot the data and add the non-linear fits to the plot

Solutions

Expert Solution

Code along with output is given above!


Related Solutions

R Programming: Load the {ISLR} and {GGally} libraries. Load and attach the College{ISLR} data set. 1.2...
R Programming: Load the {ISLR} and {GGally} libraries. Load and attach the College{ISLR} data set. 1.2 Inspect the data with the ggpairs(){GGally} function, but do not run the ggpairs plots on all variables because it will take a very long time. Only include these variables in your ggpairs plot: “Outstate”,“S.F.Ratio”,“Private”,“PhD”,“Grad.Rate”. 1.3 Briefly answer: if we are interested in predicting out of state tuition (Outstate), can you tell from the plots if any of the other variables have a curvilinear relationship...
Install and load the dataset named Carseats (in the ISLR package) into R. Run a multiple...
Install and load the dataset named Carseats (in the ISLR package) into R. Run a multiple linear regression with all the variables. Using the coefficients, write down the model. ( be careful with the qualitative variable ShelveLoc. ) obtain the interaction plot of ShelveLoc and price.
Install and load the dataset named Carseats (in the ISLR package) into R. Create a new...
Install and load the dataset named Carseats (in the ISLR package) into R. Create a new dataframe that is a copy of Carseats. Create two indicator (dummy) variables: Bad_Shelf = 1 if ShelveLoc = “Bad”, 0 otherwise Good_Shelf = 1 if ShelveLoc = “Good”, 0 otherwise Also, create two interaction variables: Price_Bad_Shelf = Price* Bad_Shelf Price_Good_Shelf = Price* Good_Shelf For Questions 1-2, please estimate a linear regression model (using the lm function) with Sales as the dependent variable and Price,...
** Number 2 implemented in R (R Studio) ** Set up the Auto data: Load the...
** Number 2 implemented in R (R Studio) ** Set up the Auto data: Load the ISLR package and the Auto data Determine the median value for mpg Use the median to create a new column in the data set named mpglevel, which is 1 if mpg>median and otherwise is 0. Make sure this variable is a factor. We will use mpglevel as the target (response) variable for the algorithms. Use the names() function to verify that your new column...
Load “Lock5Data” into your R console. Load “OlympicMarathon” data set in “Lock5Data”. This data set contains...
Load “Lock5Data” into your R console. Load “OlympicMarathon” data set in “Lock5Data”. This data set contains population of all times to finish the 2008 Olympic Men’s Marathon. a) What is the population size? b) Now using “Minutes” column generate a random sample of size 5. c) Calculate the sample mean and record it (create a excel sheet or write a direct R program to record this) d) Continue steps (b) and (c) 10,000 time (that mean you have recorded 10,000...
Please use R to do it. Using the SATGPA data set in Stat2Data package. Test by...
Please use R to do it. Using the SATGPA data set in Stat2Data package. Test by using α= .05 Question: Test if the proportion of MathSAT greater than VerbalSAT is 0.60 > library(Stat2Data) > data("SATGPA") > data(SATGPA) > SATGPA
Use R for coding Fit a density estimate to the data set `pi2000` (**UsingR**). Compare with...
Use R for coding Fit a density estimate to the data set `pi2000` (**UsingR**). Compare with the appropriate histogram. Why might you want to add an argument like `breaks = 0:10-.5` to `hist()`? I know this much code: install.packages("UsingR") library(UsingR) data(pi2000) if you put this in R a data set will appear
To import the Auto dataset into Rstudio: library("ISLR") data(Auto) view(Auto) Then, provide necessary codes for the...
To import the Auto dataset into Rstudio: library("ISLR") data(Auto) view(Auto) Then, provide necessary codes for the following: a. Use the vehicle name to name the rows and then remove the variable name from the data set since it is not of use for modelling. b. Split the data into a training set and a test set. c. Fit a regression tree to the the training set. Report the training error obtained. d. Plot the tree. e. How many terminal nodes...
Write code in R for this questions,, will vote!! Load the Taxi.txt data set into R....
Write code in R for this questions,, will vote!! Load the Taxi.txt data set into R. (a) Calculate the mean, median, standard deviation, 30th percentile, and 65th percentile for Mileage and TripTime. (b) Make a frequency table for PaymentProvider that includes a Sum column. Report the resulting table. (c) Make a contingency table comparing PaymentType and Airport. Report the resulting table. (d) Use the cor() function to find the correlation between each pair of the Meter, Tip, Mileage, and TripTime...
Using the package “wooldridge’, and the data ‘hprice1’ (in R-Software) to estimate the model price =...
Using the package “wooldridge’, and the data ‘hprice1’ (in R-Software) to estimate the model price = β0 + β1sqrft + β2bdrms + u , where is the house price measured in thousands of dollars. 1. Write out the results in equation form. 2.  What is the estimated increase in price for a house with one more bedroom, holding square footage constant? 3. What is the estimated increase in price for a house with an additional bedroom that is 140 square feet...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT