PROJEK UAS DATA ANALITIK : ANALITIKA DATA REGRESI

1. Mengimpor Kedua Dataset dari Excle ke Rstudio

library(readxl)
Financial_Data_Ratio_Q3_2022_1_ <- read_excel("C:/Users/asus/Documents/UAS DATA ANALITIK/Financial Data & Ratio - Q3 2022 (1).xlsx")
## New names:
## • `` -> `...2`
## • `` -> `...3`
## • `` -> `...4`
## • `` -> `...5`
## • `` -> `...6`
## • `` -> `...7`
## • `` -> `...8`
## • `` -> `...9`
## • `` -> `...10`
## • `` -> `...11`
## • `` -> `...12`
## • `` -> `...13`
## • `` -> `...14`
## • `` -> `...15`
## • `` -> `...16`
## • `` -> `...17`
## • `` -> `...18`
## • `` -> `...19`
## • `` -> `...20`
## • `` -> `...21`
## • `` -> `...22`
## • `` -> `...23`
## • `` -> `...24`
## • `` -> `...25`
## • `` -> `...26`
View(Financial_Data_Ratio_Q3_2022_1_)
Table_of_Stock_Price_Q3_2022 <- read_excel("C:/Users/asus/Documents/UAS DATA ANALITIK/Table of Stock Price - Q3 2022.xlsx")
## New names:
## • `` -> `...2`
## • `` -> `...3`
## • `` -> `...4`
## • `` -> `...5`
## • `` -> `...6`
## • `` -> `...7`
## • `` -> `...8`
## • `` -> `...9`
## • `` -> `...10`
## • `` -> `...11`
## • `` -> `...12`
## • `` -> `...13`
## • `` -> `...14`
## • `` -> `...15`
View(Table_of_Stock_Price_Q3_2022)

2. Menghapus Baris dan Kolom yang Kosong

FDR <- Financial_Data_Ratio_Q3_2022_1_ [-c(1:3), -c(1)]
TOSP <- Table_of_Stock_Price_Q3_2022 [-c(1:3), -c(1)]

3. Memberi Nama pada Kolom Dataset

colnames(FDR) <- c("Sektor", "Kode Sub Industri", "Sub Industri", "Kode", "Nama Emiten", "Syariah", "Tanggal LK", "Tahun Fiskal", "Jenis LK", "Opini Auditor", "Aset", "Liabilitas", "Ekuitas", "Pendapatan", "EBT", "Profit", "POA", "EPS", "BVE", "PER", "PBV", "DER", "ROA", "ROE", "NPM")

colnames(TOSP) <- c("Sektor", "Kode Sub Sektor", "Sub Sektor", "Kode","Nama Emiten", "Papan Saham", "Prev", "High", "Tanggal High", "Low", "Tanggal Low", "Closed", "Tanggal Closed", "Indeks Individu")

4. Mengubah Tipe Data dari Karakter menjadi Numerik

FDR$Aset <- as.double(FDR$Aset)
## Warning: NAs introduced by coercion
FDR$Liabilitas <- as.double(FDR$Liabilitas)
## Warning: NAs introduced by coercion
FDR$Ekuitas <- as.double(FDR$Ekuitas)
## Warning: NAs introduced by coercion
FDR$Pendapatan <- as.double(FDR$Pendapatan)
## Warning: NAs introduced by coercion
FDR$EBT <- as.double(FDR$EBT)
## Warning: NAs introduced by coercion
FDR$Profit <- as.double(FDR$Profit)
## Warning: NAs introduced by coercion
FDR$POA <- as.double(FDR$POA)
## Warning: NAs introduced by coercion
FDR$EPS <- as.double(FDR$EPS)
## Warning: NAs introduced by coercion
FDR$BVE <- as.double(FDR$BVE)
## Warning: NAs introduced by coercion
FDR$PER <- as.double(FDR$PER)
## Warning: NAs introduced by coercion
FDR$PBV <- as.double(FDR$PBV)
## Warning: NAs introduced by coercion
FDR$DER <- as.double(FDR$DER)
## Warning: NAs introduced by coercion
FDR$ROA <- as.double(FDR$ROA)
## Warning: NAs introduced by coercion
FDR$ROE <- as.double(FDR$ROE)
## Warning: NAs introduced by coercion
FDR$NPM <- as.double(FDR$NPM)
## Warning: NAs introduced by coercion
TOSP$Prev <- as.double(TOSP$Prev)
TOSP$High <- as.double(TOSP$High)
TOSP$Low <- as.double(TOSP$Low)
TOSP$Closed <- as.double(TOSP$Closed)
TOSP$'Indeks Individu' <- as.double(TOSP$`Indeks Individu`)

5. Menggabungkan Kedua Dataset menjadi Satu

Regresi_Dua_Dataset <- merge(FDR, TOSP, all = FALSE)
View(Regresi_Dua_Dataset)

6. Melakukan Uji Korelasi BVE dan EPS pada Harga Saham Closed

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.4.4     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.0
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
cor.test(Regresi_Dua_Dataset$BVE, Regresi_Dua_Dataset$ Closed, method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  Regresi_Dua_Dataset$BVE and Regresi_Dua_Dataset$Closed
## t = 22.103, df = 734, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.5866821 0.6736400
## sample estimates:
##       cor 
## 0.6321473
cor.test(Regresi_Dua_Dataset$EPS, Regresi_Dua_Dataset$ Closed, method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  Regresi_Dua_Dataset$EPS and Regresi_Dua_Dataset$Closed
## t = 32.251, df = 729, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.7351323 0.7950777
## sample estimates:
##       cor 
## 0.7667715
cor.test(Regresi_Dua_Dataset$BVE + Regresi_Dua_Dataset$EPS , Regresi_Dua_Dataset$ Closed, method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  Regresi_Dua_Dataset$BVE + Regresi_Dua_Dataset$EPS and Regresi_Dua_Dataset$Closed
## t = 25.427, df = 729, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.6451447 0.7221956
## sample estimates:
##       cor 
## 0.6855854

7. Membuat Scatterplot Menggunakan ggplot

ggplot(Regresi_Dua_Dataset, aes(BVE, Closed)) + geom_point(aes(color = Sektor)) + geom_smooth(method = "lm")
## `geom_smooth()` using formula = 'y ~ x'

ggplot(Regresi_Dua_Dataset, aes(EPS, Closed)) + geom_point(aes(color = Sektor)) + geom_smooth(method = "lm")
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 5 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 5 rows containing missing values (`geom_point()`).

ggplot(Regresi_Dua_Dataset, aes(EPS + BVE, Closed)) + geom_point(aes(color = Sektor)) + geom_smooth(method = "lm")
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 5 rows containing non-finite values (`stat_smooth()`).
## Removed 5 rows containing missing values (`geom_point()`).

8. Melakukan Uji Analisis Prediktif Regresi

library(moderndive)
Regresi_Dua_Variabel <- lm(Closed ~ EPS + BVE, data = Regresi_Dua_Dataset)
summary(Regresi_Dua_Variabel)
## 
## Call:
## lm(formula = Closed ~ EPS + BVE, data = Regresi_Dua_Dataset)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -15432   -693   -592   -177  36426 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 726.40422  110.73910   6.560 1.02e-10 ***
## EPS           4.73891    0.23814  19.900  < 2e-16 ***
## BVE           0.31160    0.04741   6.573 9.42e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2854 on 728 degrees of freedom
##   (5 observations deleted due to missingness)
## Multiple R-squared:  0.611,  Adjusted R-squared:   0.61 
## F-statistic: 571.8 on 2 and 728 DF,  p-value: < 2.2e-16
get_regression_table(Regresi_Dua_Variabel)
## # A tibble: 3 × 7
##   term      estimate std_error statistic p_value lower_ci upper_ci
##   <chr>        <dbl>     <dbl>     <dbl>   <dbl>    <dbl>    <dbl>
## 1 intercept  726.      111.         6.56       0  509.     944.   
## 2 EPS          4.74      0.238     19.9        0    4.27     5.21 
## 3 BVE          0.312     0.047      6.57       0    0.219    0.405
plot(Regresi_Dua_Variabel)

9. Hasil Interpretasi

Rumus regresi linear dua variabel: Y = β0 (intercept / bias) + β1X1 (Koefisien EPS x EPS) + β2X2 (Koefisien BVE x BVE)

Maka, Harga saham Closed = 726.40422 + (4.73891 x EPS) + (0.31160 x BVE)

10. Berapa Persen Kemampuan Prediksi Model Regresi yang Digunakan?

Dalam hasil analisis regresi, kita menggunakan metrik R^2 atau koefisien determinasi sebagai indikator kemampuan prediksi model. R^2 mengukur seberapa besar variasi dalam variabel dependen yang dapat dijelaskan oleh variabel independen yang termasuk dalam model.

Dari output regresi tersebut, didapatkan nilai R^2 sebesar 0.611 atau 61.1%, yang mengindikasikan bahwa sekitar 61.1% dari variasi dalam variabel dependen (Closed) dapat dijelaskan oleh variasi dalam variabel independen (EPS dan BVE) yang telah dimasukkan ke dalam model.

Dengan kata lain, sekitar 61.1% dari fluktuasi harga saham (Closed) dapat dijelaskan oleh variasi dalam variabel Earnings Per Share (EPS) dan Book Value of Equity (BVE) yang telah dimasukkan ke dalam model regresi ini.

11. Variabel Apa Saja yang Memiliki Nilai Prediksi Paling Besar terhadap Harga Saham?

Dalam struktur model regresi ini, dapat diamati bahwa koefisien untuk Earnings Per Share (EPS) adalah sebesar 4.73891, sementara koefisien untuk Book Value of Equity (BVE) adalah sebesar 0.31160. Oleh karena itu, dapat disimpulkan bahwa dalam konteks model ini, Earnings Per Share (EPS) memiliki dampak yang lebih besar atau nilai yang lebih tinggi terhadap perubahan harga saham closed dibandingkan dengan Book Value of Equity (BVE).