Question
The Carseats data that accompanies library(ISLR2) contains sales of child car seats at 400 different stores. To access the data, load the 'ISLR2' package and
The Carseats data that accompanies library(ISLR2) contains sales of child car seats at 400 different stores. To access the data, load the 'ISLR2' package and call the `Carseats` data as illustrated below.
library(ISLR2) data(Carseats)
Use simple random sampling to split the data into a train and test sample with 80% of the data in the train sample. Use a seed of 617. Compute the average price in the train sample and in the test sample. What is the absolute difference in average price between the train and test samples?
Now, use stratified sampling to split the "Carseats" data into a train and test sample with 80% of the data in the train sample. Do the sampling in such a way that the distribution of "price" is approximately equal in both samples. Use a seed of 617 and utilize "createDataPartition", for the split and set groups to 10. Compute the average price in the train sample and in the test sample. What is the absolute difference in average price between the train and test samples? Since you are asked absolute difference, if the difference is negative, drop the negative sign.
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