install.packages("tidyverse")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
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)
This is the end of part 1 for my explanatory analysis.
library(ggplot2)
head(ad_sales)
ggplot(data = ad_sales, aes(x = TV)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
This is the end of part 2 for my explantory analysis.
#Question 1
There is a relationship between x and y. The relationship looks linear.
#Question 2
A coefficient represents the change in a n dependent variable for a unit change in an independent variable. There is a positive relationship between TV advertising and sales which means as TV ads spending increases the sales increase as well.
#Question 3
The equation of a simple linear regression depicts a dependency relationship between two variables or two sets of variables.
#Question 4
library(ggplot2)
ggplot(ad_sales,aes(x = radio, y = sales)) +
geom_point(colorr= "blue") +
geom_smooth(method = "Im", colorr = "red" )+
labs( title = " Sales vs. Radio Advertising",
x = "Radio Advertsing Budget",
y = "Sales") +
theme_minimal()
## Warning in geom_point(colorr = "blue"): Ignoring unknown parameters: `colourr`
## Warning in geom_smooth(method = "Im", colorr = "red"): Ignoring unknown
## parameters: `colourr`
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Failed to fit group -1.
## Caused by error in `compute_group()`:
## ! object 'weight' not found
#Question 5