asked 184k views
4 votes
Write an r function to predict the sales given a tv advertising budget value,

1 Answer

4 votes

Final answer:

An R function to predict sales from a TV advertising budget can be created using the linear regression model provided. You simply insert the desired day into the function to get the predicted sales for that day.

Step-by-step explanation:

To predict sales given a TV advertising budget value, an R function based on the provided linear regression model (ŷ = 101.32 + 2.48x) can be written. Here, we assumed ŷ represents the sales in thousands of dollars, and x is the day.

R Function to Predict Sales

The R function would look like this:

predict_sales <- function(day) {
estimated_sales <- 101.32 + 2.48 * day
return(estimated_sales)
}

To predict the sales on day 60, you would use this function as follows:

predict_sales(60)

Similarly, to predict the sales on day 90:

predict_sales(90)

This function will return the predicted sales values for these days based on the linear regression model.

answered
User Chamod Pathirana
by
7.9k points

No related questions found