library(ggplot2) ggplot(salesData, aes(x = expenditures, y = sales)) + geom_point() + labs(title = "Scatter Plot of Sales vs Advertisement Expenditure", x = "Advertisement Expenditure ($1000)", y = "Sales ($1000)") + theme_minimal() correlation <- cor(salesData$expenditures, salesData$sales) print(paste("Correlation Coefficient:", correlation)) cor_test <- cor.test(salesData$expenditures, salesData$sales) print(cor_test) lm_model <- lm(sales ~ expenditures, data = salesData) coefficients <- summary(lm_model)$coefficients print(coefficients) ggplot(salesData, aes(x = expenditures, y = sales)) + geom_point() + geom_smooth(method = "lm", se = FALSE, color = "blue") + labs(title = "Scatter Plot of Sales vs Advertisement Expenditure with Regression Line", x = "Advertisement Expenditure ($1000)", y = "Sales ($1000)") + theme_minimal() r_squared <- summary(lm_model)$r.squared print(paste("R²:", r_squared)) se <- summary(lm_model)$sigma print(paste("Standard Error of the Estimate (se):", se)) sb1 <- summary(lm_model)$coefficients[2, "Std. Error"] print(paste("Standard Error of the Slope (sb1):", sb1)) slope_test <- summary(lm_model)$coefficients[2, ] print(slope_test) new_expenditure <- data.frame(expenditures = 3260) predicted_sales <- predict(lm_model, new_expenditure) print(paste("Predicted Sales for $3260 Expenditure:", predicted_sales)) prediction_interval <- predict(lm_model, new_expenditure, interval = "prediction", level = 0.95) print(prediction_interval)