##Hypotheses Null Hypothesis (H0): There is no relationship between the number of laptops purchased and the number of anti-virus licenses purchased.

Alternative Hypothesis (H1): There is a positive relationship between the number of laptops purchased and the number of anti-virus licenses purchased.

#install packages
#Load packages
library(readxl)
library(psych)
dataset <- read_excel("C:/Users/odhee/Downloads/A5RQ2.xlsx")
# CALCULATE THE DESCRIPTIVE DATA
describe(dataset[, 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
# CREATE A HISTOGRAM FOR ANTIVIRUS
hist(dataset$Antivirus,
     main = "Histogram of Antivirus",
     xlab = "Value",
     ylab = "Frequency",
     col = "lightgreen",
     border = "black",
     breaks = 20)

# CREATE A HISTOGRAM FOR LAPTOP
hist(dataset$Laptop,
     main = "Histogram of Laptop",
     xlab = "Value",
     ylab = "Frequency",
     col = "lightblue",
     border = "black",
     breaks = 20)

# CONDUCT THE SHAPIRO-WILK TEST

shapiro.test(dataset$Antivirus)
## 
##  Shapiro-Wilk normality test
## 
## data:  dataset$Antivirus
## W = 0.99419, p-value = 0.8981
shapiro.test(dataset$Laptop)
## 
##  Shapiro-Wilk normality test
## 
## data:  dataset$Laptop
## W = 0.99362, p-value = 0.8559

Normality Test: Antivirus Licenses: W = 0.99419, p-value = 0.8981 - Normally distributed Laptops Purchased: W = 0.99362, p-value = 0.8559 - Normally distributed

Decision: Since both variables are normally distributed, we will use Pearson Correlation Test.

library(ggplot2)
## 
## Attaching package: 'ggplot2'
## The following objects are masked from 'package:psych':
## 
##     %+%, alpha
library(ggpubr)
# CREATE A SCATTERPLOT
ggscatter(dataset, x = "Antivirus", y = "Laptop",
          add = "reg.line",
          conf.int = TRUE,
          cor.coef = TRUE,
          cor.method = "pearson",
          xlab = "Antivirus", 
          ylab = "Laptop")

Scatterplot Observation The line is pointing upward. So, the relationship is positive. As antivirus licenses increase, laptop purchases also increases.

# CONDUCT THE PEARSON CORRELATION TEST
cor.test(dataset$Antivirus, dataset$Laptop, method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  dataset$Antivirus and dataset$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

The name of the inferential test used is Pearson Correlation Test. The names of the two variables analyzed are Antivirus license purchased and laptops purchased. The total sample size n=122. The test results are statistically significant. The mean and SD for each variable. Antivirus: M = 50.18, SD = 13.36 Laptop: M = 40.02, SD = 12.30 The direction and size of the correlation are positive and strong. Degrees of freedom (df) is 120 rho-value- 0.92 EXACT p-value- p < .001

Final Report: A Pearson correlation was conducted to examine the relationship between Antivirus licenses and Laptops purchased (n = 122). There was a statistically significant correlation between antivirus licenses (M = 50.18, SD = 13.36) and laptops purchased (M = 40.02, SD = 12.30). The correlation was positive and very strong, r(120) = 0.92, p < .001. As Antivirus licenses purchased increases, Laptops purchased also increases.