ISYE 6414 HW4
Background
The dataset includes information on a specific product from an undisclosed brand. Each row in the dataset
represents the sales volume for a week, along with details about the marketing campaigns and promotional
methods used for the product throughout the two-year duration. The specific product and corresponding
years for this data remain unknown.The dataset is obtained from kaggle linear regression datasets.
The dataset consists of 992 observations of 8 attributes. Below is a brief description of each feature and the
response variable (Sale) in our dataset:
1. Sale: This variable contains numerical data representing the number of product sales for each observed
week.
2. Price: The observed week’s base price for the product.
3. Radio: The number of radio advertisements or campaigns promoting the product for the observed
week.
4. Discount: The discount rate applicable for the observed week.
5. TVSpending: The average expenditure on television campaigns during the observed week.
6. StockRate: The stock-out rate, calculated as the number of times the product was out of stock divided
by the total number of product visits.
7. OnlineAdsSpending: The online ads spending, calculated the total amount of spend on online
advertising.
Please load the dataset “market_data.csv” and then split the dataset into a train and test set in a 80:20 ratio.
Use the training set to build the models in Questions 1-6. Use the test set to help evaluate model performance
in Question 7. Please make sure that you are using R version 3.6.X or above (i.e. version 4.X is also
acceptable).
Note : Note : Owing to the different scales of variance in explanatory columns , all the explanatory columns
have been standardized with mean as 0 and variance as 1.this is important as the different models used in this
assignment can be error prone/affected is the columns are not standardized.
,Read Data
#install.packages("CombMSC")
#install.packages("olsrr")
#fullData <- fullData[, -which(names(fullData) == "InStrSpending")]
# Import the libraries
, ## Sale Discount TVSpending StockRate Price Radio
## 1 240368 1.43769923 -0.9174999 -0.1553245 -0.2341632 -0.46845434
## 2 207276 0.95585245 1.1951829 -1.5506783 -1.0515075 0.39823853
## 3 172572 1.09352296 -0.4380693 -1.5157945 -1.2696190 -1.00858366
## 4 82697 0.12982940 -1.1338305 1.3446808 1.6415960 -0.08200198
## 5 141762 0.06099414 -0.2811201 -0.4692791 -1.1410480 0.65248350
## 6 271990 -0.55852315 1.0874555 1.5191000 0.1148152 0.27507096
## OnlineAdsSpending
## 1 -0.55544799
## 2 -1.01969466
## 3 -0.57167225
## 4 0.27914100
## 5 0.01338255
## 6 1.42370602
Note: Use the training set to build the models in Questions 1-6. Use the test set to help evaluate model
performance in Question 7.
Question 1: Full Model
a. Fit a multiple linear regression with the variable Sale as the response and the other variables as
predictors. Call it model1. Display the model summary.
## -92999 -42488 863 41966 99535
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 172157 1778 96.829 < 2e-16 ***
## Discount 3314 1796 1.845 0.06539 .
## TVSpending 33704 1782 18.918 < 2e-16 ***
## StockRate -3490 1782 -1.959 0.05051 .
## Price -54931 1784 -30.797 < 2e-16 ***
## Radio -4889 1770 -2.762 0.00589 **
## OnlineAdsSpending 1516 1792 0.846 0.39790
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 50090 on 787 degrees of freedom
## Multiple R-squared: 0.629, Adjusted R-squared: 0.6262
## F-statistic: 222.4 on 6 and 787 DF, p-value: < 2.2e-16
b. Which regression coefficients are significant at the 90% confidence level? At the 95% confidence level?
Background
The dataset includes information on a specific product from an undisclosed brand. Each row in the dataset
represents the sales volume for a week, along with details about the marketing campaigns and promotional
methods used for the product throughout the two-year duration. The specific product and corresponding
years for this data remain unknown.The dataset is obtained from kaggle linear regression datasets.
The dataset consists of 992 observations of 8 attributes. Below is a brief description of each feature and the
response variable (Sale) in our dataset:
1. Sale: This variable contains numerical data representing the number of product sales for each observed
week.
2. Price: The observed week’s base price for the product.
3. Radio: The number of radio advertisements or campaigns promoting the product for the observed
week.
4. Discount: The discount rate applicable for the observed week.
5. TVSpending: The average expenditure on television campaigns during the observed week.
6. StockRate: The stock-out rate, calculated as the number of times the product was out of stock divided
by the total number of product visits.
7. OnlineAdsSpending: The online ads spending, calculated the total amount of spend on online
advertising.
Please load the dataset “market_data.csv” and then split the dataset into a train and test set in a 80:20 ratio.
Use the training set to build the models in Questions 1-6. Use the test set to help evaluate model performance
in Question 7. Please make sure that you are using R version 3.6.X or above (i.e. version 4.X is also
acceptable).
Note : Note : Owing to the different scales of variance in explanatory columns , all the explanatory columns
have been standardized with mean as 0 and variance as 1.this is important as the different models used in this
assignment can be error prone/affected is the columns are not standardized.
,Read Data
#install.packages("CombMSC")
#install.packages("olsrr")
#fullData <- fullData[, -which(names(fullData) == "InStrSpending")]
# Import the libraries
, ## Sale Discount TVSpending StockRate Price Radio
## 1 240368 1.43769923 -0.9174999 -0.1553245 -0.2341632 -0.46845434
## 2 207276 0.95585245 1.1951829 -1.5506783 -1.0515075 0.39823853
## 3 172572 1.09352296 -0.4380693 -1.5157945 -1.2696190 -1.00858366
## 4 82697 0.12982940 -1.1338305 1.3446808 1.6415960 -0.08200198
## 5 141762 0.06099414 -0.2811201 -0.4692791 -1.1410480 0.65248350
## 6 271990 -0.55852315 1.0874555 1.5191000 0.1148152 0.27507096
## OnlineAdsSpending
## 1 -0.55544799
## 2 -1.01969466
## 3 -0.57167225
## 4 0.27914100
## 5 0.01338255
## 6 1.42370602
Note: Use the training set to build the models in Questions 1-6. Use the test set to help evaluate model
performance in Question 7.
Question 1: Full Model
a. Fit a multiple linear regression with the variable Sale as the response and the other variables as
predictors. Call it model1. Display the model summary.
## -92999 -42488 863 41966 99535
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 172157 1778 96.829 < 2e-16 ***
## Discount 3314 1796 1.845 0.06539 .
## TVSpending 33704 1782 18.918 < 2e-16 ***
## StockRate -3490 1782 -1.959 0.05051 .
## Price -54931 1784 -30.797 < 2e-16 ***
## Radio -4889 1770 -2.762 0.00589 **
## OnlineAdsSpending 1516 1792 0.846 0.39790
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 50090 on 787 degrees of freedom
## Multiple R-squared: 0.629, Adjusted R-squared: 0.6262
## F-statistic: 222.4 on 6 and 787 DF, p-value: < 2.2e-16
b. Which regression coefficients are significant at the 90% confidence level? At the 95% confidence level?