This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
Note: this analysis was performed using the open source software R and Rstudio.
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)
plot(sales ~ radio, data = ad_sales)
library(ggplot2)
head(ad_sales)
## # A tibble: 6 × 6
## ...1 X1 TV radio newspaper sales
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1 1 230. 37.8 69.2 22.1
## 2 2 2 44.5 39.3 45.1 10.4
## 3 3 3 17.2 45.9 69.3 9.3
## 4 4 4 152. 41.3 58.5 18.5
## 5 5 5 181. 10.8 58.4 12.9
## 6 6 6 8.7 48.9 75 7.2
ggplot(data = ad_sales, aes(x = TV)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Based on the scatter plot, there does seem to be a direct relationship between x and y. On the graph, TV advertising is represented by the variable x and sales are represented by the variable y. The data moves in an upward direction, meaning as the advertisements for TV increase, so do the TV sales.
A coefficient tells you the relationship between two variables. It depicts how the dependent variable will change when the independent variable changes. The relationship between TV advertising–independent variable–and sales–dependent variable–is positive because the graph shows an upward trend. As TV advertising increases, the sales for Tvs increase as well.
A simple regression line can address multiple marketing questions, such as how does advertising for a product affect its sales, or how does the price of a product affect its sales. Looking at the data on a visual graph can help marketing analysts to create a future strategy to improve operations. A possible limitation to simple regression analysis is that it is limited to one independent variable, making it difficult to analyze trends when there are multiple independent variables to look at.
Looking at the scatter plot, the relationship between radio advertising and sales is also positive. As advertisements for radios increase, so do the sales. This makes sense because the relationship was the same for the TV advertisements and sales on TVs.
library(ggplot2)
head(ad_sales)
## # A tibble: 6 × 6
## ...1 X1 TV radio newspaper sales
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1 1 230. 37.8 69.2 22.1
## 2 2 2 44.5 39.3 45.1 10.4
## 3 3 3 17.2 45.9 69.3 9.3
## 4 4 4 152. 41.3 58.5 18.5
## 5 5 5 181. 10.8 58.4 12.9
## 6 6 6 8.7 48.9 75 7.2
ggplot(data = ad_sales, aes(x = radio)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.