Lab 2 - Analyzing the effectiveness of advertising campaigns

Quarto

Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see https://quarto.org.

Running Code

When you click the Render button a document will be generated that includes both content and the output of embedded code.

Data

We will be using a dataset that is hosted on my Github website.

You can embed code like this:

library(readr)
library(readr)
ad_sales <- read_csv('https://raw.githubusercontent.com/utjimmyx/regression/master/advertising.csv')
New names:
Rows: 200 Columns: 6
── Column specification
──────────────────────────────────────────────────────── Delimiter: "," dbl
(6): ...1, X1, TV, radio, newspaper, sales
ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
Specify the column types or set `show_col_types = FALSE` to quiet this message.
• `` -> `...1`
plot(sales ~ TV, data = ad_sales)

Now let’s fit a linear model with TV advertising as a predictor.

fit <- lm(sales ~ TV, data = ad_sales)
summary(fit)

Call:
lm(formula = sales ~ TV, data = ad_sales)

Residuals:
    Min      1Q  Median      3Q     Max 
-8.3860 -1.9545 -0.1913  2.0671  7.2124 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) 7.032594   0.457843   15.36   <2e-16 ***
TV          0.047537   0.002691   17.67   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 3.259 on 198 degrees of freedom
Multiple R-squared:  0.6119,    Adjusted R-squared:  0.6099 
F-statistic: 312.1 on 1 and 198 DF,  p-value: < 2.2e-16

Question 2:Is there a relationship between TV advertising and Sales? If so, what does the relationship look like? Explain the coefficient and R square.

Your answer here

Question 3:Can you plot the relationship between radio advertising and Sales? If so, please save it as fit1. What does the relationship look like? Explain the coefficients and R square.

Your answer here

Question 4:Can you plot the relationship between radio advertising (X1), TV advertising (X2), and Sales (Y)? If so, please save it as fit2. What does the relationship look like? Explain the coefficients and R square.

Your answer here

Question 4: Two things you learned from this session

Your answer here