#H0: There is no relation between the number of laptops purchased and the number of anti-virus licenses purchased. # H1: There is a relation between the number of laptops purchased and the number of anti-virus licenses purchased.
options(repos = c(CRAN = "https://cloud.r-project.org"))
install.packages("readxl")
## Installing package into 'C:/Users/mnava/AppData/Local/R/win-library/4.5'
## (as 'lib' is unspecified)
## package 'readxl' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\mnava\AppData\Local\Temp\Rtmp4wg1Nd\downloaded_packages
library(readxl)
A5RQ2<- read_excel("D:\\Ms Analytics 2025\\Fall 1\\Applied Analytics &Methods 1\\Week 5\\A5RQ2.xlsx")
install.packages("psych")#
## Installing package into 'C:/Users/mnava/AppData/Local/R/win-library/4.5'
## (as 'lib' is unspecified)
## package 'psych' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\mnava\AppData\Local\Temp\Rtmp4wg1Nd\downloaded_packages
library(psych)#
describe(A5RQ2[, c("Antivirus", "Laptop")])
## vars n mean sd median trimmed mad min max range skew
## Antivirus 1 122 50.18 13.36 49 49.92 12.60 15 83 68 0.15
## Laptop 2 122 40.02 12.30 39 39.93 11.86 8 68 60 -0.01
## kurtosis se
## Antivirus -0.14 1.21
## Laptop -0.32 1.11
install.packages("ggplot2")#
## Installing package into 'C:/Users/mnava/AppData/Local/R/win-library/4.5'
## (as 'lib' is unspecified)
## package 'ggplot2' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\mnava\AppData\Local\Temp\Rtmp4wg1Nd\downloaded_packages
install.packages("ggpubr")#
## Installing package into 'C:/Users/mnava/AppData/Local/R/win-library/4.5'
## (as 'lib' is unspecified)
## package 'ggpubr' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\mnava\AppData\Local\Temp\Rtmp4wg1Nd\downloaded_packages
library(ggplot2)
##
## Attaching package: 'ggplot2'
## The following objects are masked from 'package:psych':
##
## %+%, alpha
library(ggpubr)
ggscatter(A5RQ2, x = "Antivirus", y = "Laptop",
add = "reg.line",
conf.int = TRUE,
cor.coef = TRUE,
cor.method = "pearson",
xlab = "Antivirus", ylab = "Laptop")
#The relationship is positive since the line is pointing up. # ………………………………………………..
hist(A5RQ2$Antivirus,
main = "Histogram of Antivirus",
xlab = "Value",
ylab = "Frequency",
col = "lightblue",
border = "black",
breaks = 20)
hist(A5RQ2$Laptop,
main = "Histogram of Laptop",
xlab = "Value",
ylab = "Frequency",
col = "lightgreen",
border = "black",
breaks = 20)
#The histogram for Antivirus is not symmetrical, it is positively skewed. #In our opinion the histogram of antivirus is too tall. #The Histogram for Laptops is not symmetrical, it is negatively skewed. #In our opinion the histogram laptops is a bell curve. # ………………………………………………..
shapiro.test(A5RQ2$Antivirus)
##
## Shapiro-Wilk normality test
##
## data: A5RQ2$Antivirus
## W = 0.99419, p-value = 0.8981
shapiro.test(A5RQ2$Laptop)
##
## Shapiro-Wilk normality test
##
## data: A5RQ2$Laptop
## W = 0.99362, p-value = 0.8559
#The data is normal for both variables, we continue with the Pearson Correlation test. # ================================================ # PEARSON CORRELATION TEST # ================================================
cor.test(A5RQ2$Antivirus, A5RQ2$Laptop, method = "pearson")
##
## Pearson's product-moment correlation
##
## data: A5RQ2$Antivirus and A5RQ2$Laptop
## t = 25.16, df = 120, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.8830253 0.9412249
## sample estimates:
## cor
## 0.9168679
#mean = 50.8, SD = 13.36-Antivirus #Mean = 40.02, SD = 12.30 -Laptops # The relationship is positive since the line is pointing up # Degrees of freedom = 120 # r-value =0.9168 # p-value p = 2.26 epower -16 => p<0.001 # ………………………………………………..