R Markdown

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.

Objective

The objective of this tutorial is to explain how bivariate analysis works.This analysis can be used by marketers to make decisions about their pricing strategies, advertising strategies, and promotion stratgies among others.

Bivariate analysis is one of the simplest forms of statistical analysis. It is generally used to find out if there is a relationship between two sets of values (or two variables). That said, it usually involves the variables X and Y (statisticshowto.com).

Dataset - We will be using two online datasets available in R for this tutorial

plot(y3 ~ x2, data = anscombe, pch = 16)
abline(lm(y3 ~ x3, anscombe), col = "grey20")

Question 1:is there a relationship between x and y? If so, what does the relationship look like?

Yes, there is a relationship between x and y.This is a positive relationship.

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)

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

There is a relationship between TV advertising and Sales. This is a positive relationship.

Question 3:Can you plot the relationship between radio advertising and Sales? If so, what does the relationship look like?

plot(sales ~ radio, data = ad_sales)

The relationship between radio ads and sales is positive, however, it is a weaker relationship.

###Question 4:Are there any other kinds of exploratory analysis you can perform using R? If so, please include your analysis and results in your final report.

# Build a multiple regression model
model <- lm(sales ~ TV + radio, data = ad_sales)

# View the results
summary(model)
## 
## Call:
## lm(formula = sales ~ TV + radio, data = ad_sales)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -8.7977 -0.8752  0.2422  1.1708  2.8328 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  2.92110    0.29449   9.919   <2e-16 ***
## TV           0.04575    0.00139  32.909   <2e-16 ***
## radio        0.18799    0.00804  23.382   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.681 on 197 degrees of freedom
## Multiple R-squared:  0.8972, Adjusted R-squared:  0.8962 
## F-statistic: 859.6 on 2 and 197 DF,  p-value: < 2.2e-16

###Question 5: Visit the avocado dataset available in week 2, raise one question you could possibly answer with the data, and explain how a stakeholder could benefit from your proposed analysis. Using the avocado data set, does average price affect total volume of sales? A stakeholder (grocery store) can benefit from analyzing this type of question by examining if sales decline based on certain prices and adjust the pricing/and or implement a strategy to increase sales, such as coupons. ## References

Bivariate Analysis Definition & Example https://www.statisticshowto.com/bivariate-analysis/#:~:text=Bivariate%20analysis%20means%20the%20analysis,the%20variables%20X%20and%20Y.

https://www.sciencedirect.com/topics/mathematics/bivariate-data