library(readxl)
## Warning: package 'readxl' was built under R version 4.4.2
###Input Data
data<-read_excel(path = "C:/Users/FAQIH/Downloads/Data Latihan 1 Analisis Regresi.xlsx", col_names = TRUE)
data
###Scatterplot
plot(data$Page, data$`Price ($)`, main = "Scatterplot Halaman dan Harga Buku",
xlab = "Page", ylab = "Price")
###Korelasi Page vs Price($)
korelasi <- cor(data$Page, data$`Price ($)`, method = "pearson")
korelasi
## [1] 0.6138789
###Matriks Korelasi
df<-data.frame(data$Page,data$`Price ($)`)
korelasi<-cor(df)
korelasi
## data.Page data..Price.....
## data.Page 1.0000000 0.6138789
## data..Price..... 0.6138789 1.0000000
###corrplot Page vs Price($)
library("corrplot")
## Warning: package 'corrplot' was built under R version 4.4.2
## corrplot 0.95 loaded
corrplot(corr = korelasi, method = "number", type = "upper")
###Uji Signifikansi Koefisien Korelasi ### Hipotesis H0: rho=0 vs H1:
rho != 0
cor.test(x=data$Page, y=data$`Price ($)`, alternative = "two.sided",
method = "pearson",
exact = NULL, conf.level = 0.95)
##
## Pearson's product-moment correlation
##
## data: data$Page and data$`Price ($)`
## t = 1.9049, df = 6, p-value = 0.1055
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.1600131 0.9204012
## sample estimates:
## cor
## 0.6138789
Nilai p (p-value = 0.1055): karena nilai p > 0.05, maka belum cukup bukti untuk menolak H0 dan dapat disimpulkan bahwa korelasi antara page dan price tidak signifikan