Data cleaning dan manipulasi data diperlukan karena ada beberapa inkonsistensi pada penulisan nama perusahaan:
Perusahaan yang sama ada yang ditulis menggunakan nama awalan PT, dan ada yang tidak ditulis menggunakan nama awalan PT (contoh: PT Adaro dan Adaro)
Perusahaan yang sama ada yang ditulis menggunakan akhiran tbk., dan ada yang menggunakan tbk saja (contoh: Antam tbk dengan Antam tbk.).
Data yang digunakan untuk project analisis regresi ini adalah Table Of Stock Price dan Financial Data and Ratio triwulan ke 3 tahun 2022. Kedua data ini diambil dari website IDX.
library(readxl)
Table_of_Stock_price_Q3_2022 <- read_excel("D:/KULIAH PIERRE/SEMESTER 5/Data Analitik (Anindyo Aji Susanto)/Pertemuan 16 (UAS)/Project 2 (Rstudio)/Table of Stock Price - Q3 2022.xlsx")
## New names:
## • `` -> `...2`
## • `` -> `...3`
## • `` -> `...4`
## • `` -> `...5`
## • `` -> `...6`
## • `` -> `...7`
## • `` -> `...8`
## • `` -> `...9`
## • `` -> `...10`
## • `` -> `...11`
## • `` -> `...12`
## • `` -> `...13`
## • `` -> `...14`
## • `` -> `...15`
Financial_Data_and_Ratio_Q3_2022 <- read_excel ("D:/KULIAH PIERRE/SEMESTER 5/Data Analitik (Anindyo Aji Susanto)/Pertemuan 16 (UAS)/Project 2 (Rstudio)/Financial Data & Ratio - Q3 2022.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(Table_of_Stock_price_Q3_2022)
View(Financial_Data_and_Ratio_Q3_2022)
fdr <- Financial_Data_and_Ratio_Q3_2022 [-c(1:3),-c(1)]
tsp <- Table_of_Stock_price_Q3_2022 [-c(1:3),-c(1)]
View(fdr)
View(tsp)
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(tsp) <- c("Sektor", "Kode Sub Sektor", "Sub Sektor", "Kode","Nama Emiten", "Papan Saham", "Prev", "High", "Tanggal High", "Low", "Tanggal Low", "Closed", "Tanggal Closed", "Indeks Individu")
View(fdr)
View(tsp)
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
tsp$`Prev` <- as.double(tsp$`Prev`)
tsp$`High` <- as.double(tsp$`High`)
tsp$`Low` <- as.double(tsp$`Low`)
tsp$`Closed` <- as.double(tsp$`Closed`)
tsp$`Indeks Individu` <- as.double(tsp$`Indeks Individu`)
Regresi_DA<- merge(fdr,tsp, all = FALSE)
View(Regresi_DA)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.3 ✔ 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
ggplot(Regresi_DA, aes(Closed, EPS)) + 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_DA, aes(Closed, BVE)) + geom_point(aes(color = Sektor)) + geom_smooth(method = "lm")
## `geom_smooth()` using formula = 'y ~ x'
ggplot(Regresi_DA, aes(Closed, EPS + BVE)) + 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()`).
cor.test(Regresi_DA$EPS, Regresi_DA$Closed, method = "pearson")
##
## Pearson's product-moment correlation
##
## data: Regresi_DA$EPS and Regresi_DA$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
Hasil uji korelasi menunjukkan bahwa ada korelasi yang sangat kuat antara EPS dengan harga saham Closed
cor.test(Regresi_DA$BVE, Regresi_DA$Closed, method = "pearson")
##
## Pearson's product-moment correlation
##
## data: Regresi_DA$BVE and Regresi_DA$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
Hasil uji korelasi menunjukkan bahwa ada korelasi yang cukup kuat antara BVE dengan harga saham Closed
cor.test(Regresi_DA$EPS + Regresi_DA$BVE, Regresi_DA$Closed, method = "pearson")
##
## Pearson's product-moment correlation
##
## data: Regresi_DA$EPS + Regresi_DA$BVE and Regresi_DA$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
Hasil uji korelasi menunjukkan bahwa ada korelasi yang cukup kuat antara BVE dan EPS dengan harga saham Closed
library(moderndive)
Regresi <- lm(Closed ~ EPS + BVE, data = Regresi_DA)
summary (Regresi)
##
## Call:
## lm(formula = Closed ~ EPS + BVE, data = Regresi_DA)
##
## 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)
## # 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)
Dari hasil prediksi regresi tadi, ditemukanlah regresi untuk harga saham closed dengan rumus regresi linear: 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)
Dalam output analisis regresi, metrik yang digunakan untuk mengukur kemampuan prediksi model adalah R^2 (R-squared) atau koefisien determinasi. R^2 menunjukkan seberapa besar variasi dalam variabel dependen yang dapat dijelaskan oleh variabel independen yang ada dalam model.
Dari hasil regresi tadi, R^2 nya adalah 0.611 atau 61.1%, yang menandakan bahwa sekitar 61.1% variasi dalam variabel dependen (Closed) dapat dijelaskan oleh variabel independen (EPS dan BVE) yang ada dalam model.
Jadi, 61.1% dari variasi dalam harga saham (Closed) dapat dijelaskan oleh variasi dalam variabel Earnings Per Share (EPS) dan Book Value of Equity (BVE) dalam model regresi ini.
Koefisien EPS = 4.73891, sedangakan koefisien BVE = 0.31160. Maka dalam model regresi ini, EPS lah yang memiliki nilai / pengaruh paling besar terhadap harga saham closed.