library(googlesheets4)
googlesheets4::gs4_deauth()
fdr <- read_sheet("1yLiaTItgaZfg_fSejwGJmO-rWrwbya-MZHceeVC0tK4")✔ Reading from "Financial Data & Ratio - Q3 2022".
✔ Range 'Sheet1'.
View(fdr)library(googlesheets4)
googlesheets4::gs4_deauth()
fdr <- read_sheet("1yLiaTItgaZfg_fSejwGJmO-rWrwbya-MZHceeVC0tK4")✔ Reading from "Financial Data & Ratio - Q3 2022".
✔ Range 'Sheet1'.
View(fdr)Data preparation dan mencari harga saham sudah saya lakukan di google sheet dengan cara BV x PBV
fdr$Assets <- as.double(fdr$Assets)
fdr$Liabilities <- as.double(fdr$Liabilities)
fdr$Equity <- as.double(fdr$Equity)
fdr$Sales <- as.double(fdr$Sales)Warning: NAs introduced by coercion
Warning: NAs introduced by coercion
Warning: NAs introduced by coercion
fdr$EBT <- as.double(fdr$EBT)
fdr$Profit <- as.double(fdr$Profit)
fdr$POA <- as.double(fdr$POA)
fdr$EPS <- as.double(fdr$EPS)
fdr$BV <- as.double(fdr$BV)
fdr$PER <- as.double(fdr$PER)
fdr$PBV <- as.double(fdr$PBV)
fdr$DER <- as.double(fdr$DER)
fdr$ROA <- as.double(fdr$ROA)
fdr$ROE <- as.double(fdr$ROE)
fdr$NPM <- as.double(fdr$NPM)
fdr$`Stock Price` <- as.double(fdr$`Stock Price`)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
library(ggplot2)
ggplot(fdr, aes(Sales, `Stock Price`)) + geom_point(aes(color = Sector)) + geom_smooth(method = "lm")`geom_smooth()` using formula = 'y ~ x'
Warning: Removed 3 rows containing non-finite values (`stat_smooth()`).
Warning: Removed 3 rows containing missing values (`geom_point()`).
library(tidyverse)
library(ggplot2)
ggplot(fdr, aes(EPS, `Stock Price`)) + geom_point(aes(color = Sector)) + geom_smooth(method = "lm")`geom_smooth()` using formula = 'y ~ x'
library(tidyverse)
library(ggplot2)
ggplot(fdr, aes(BV, `Stock Price`)) + geom_point(aes(color = Sector)) + geom_smooth(method = "lm")`geom_smooth()` using formula = 'y ~ x'
library(tidyverse)
library(ggplot2)
ggplot(fdr, aes(Sales + EPS + BV , `Stock Price`)) + geom_point(aes(color = Sector)) + geom_smooth(method = "lm")`geom_smooth()` using formula = 'y ~ x'
Warning: Removed 3 rows containing non-finite values (`stat_smooth()`).
Warning: Removed 3 rows containing missing values (`geom_point()`).
cor.test(fdr$`Stock Price`, fdr$Sales, method = "pearson")
Pearson's product-moment correlation
data: fdr$`Stock Price` and fdr$Sales
t = 10.668, df = 804, p-value < 2.2e-16
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.2901434 0.4111996
sample estimates:
cor
0.3521434
cor.test(fdr$`Stock Price`, fdr$EPS, method = "pearson")
Pearson's product-moment correlation
data: fdr$`Stock Price` and fdr$EPS
t = 15.741, df = 807, p-value < 2.2e-16
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.4301111 0.5357009
sample estimates:
cor
0.4846697
cor.test(fdr$`Stock Price`, fdr$BV, method = "pearson")
Pearson's product-moment correlation
data: fdr$`Stock Price` and fdr$BV
t = 9.4059, df = 807, p-value < 2.2e-16
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.2508282 0.3751215
sample estimates:
cor
0.3143213
Dari hasil uji korelasi berikut urutan variable yang memiliki korelasi tertinggi hingga terendah terhadap Stock Price:
EPS (Earning Per Share) dengan korelasi sebesar 0.4846697
Sales (Price Earning Ratio) dengan korelasi sebesar 0.3521434
BV (Book Value) dengan korelasi sebesar 0.3143213
cor.test(fdr$`Stock Price`, fdr$Sales + fdr$EPS + fdr$BV, method = "pearson")
Pearson's product-moment correlation
data: fdr$`Stock Price` and fdr$Sales + fdr$EPS + fdr$BV
t = 14.754, df = 804, p-value < 2.2e-16
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.4054613 0.5142559
sample estimates:
cor
0.4615925
Berdasarkan hasil uji korelasi didapatka korelasi variable Sales, EPS, dan BV terhadap Stock Price sebesar 0.4615925
library(moderndive)
regresi <- lm(fdr$`Stock Price`~EPS+BV+Sales, fdr)plot(regresi)summary(regresi)
Call:
lm(formula = fdr$`Stock Price` ~ EPS + BV + Sales, data = fdr)
Residuals:
Min 1Q Median 3Q Max
-21831 -871 -751 -289 51229
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 923.83914 134.53641 6.867 1.32e-11 ***
EPS 1.35134 0.11439 11.814 < 2e-16 ***
BV -0.01992 0.01384 -1.439 0.151
Sales 0.13887 0.01365 10.176 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 3628 on 802 degrees of freedom
(3 observations deleted due to missingness)
Multiple R-squared: 0.3241, Adjusted R-squared: 0.3216
F-statistic: 128.2 on 3 and 802 DF, p-value: < 2.2e-16
get_regression_table(regresi)# A tibble: 4 × 7
term estimate std_error statistic p_value lower_ci upper_ci
<chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 intercept 924. 135. 6.87 0 660. 1188.
2 EPS 1.35 0.114 11.8 0 1.13 1.58
3 BV -0.02 0.014 -1.44 0.151 -0.047 0.007
4 Sales 0.139 0.014 10.2 0 0.112 0.166
Secara signifikan nilai Adjusted R-squared dari variable EPS, BV, dan Sales hanya memiliki tingkat perdiksi dari model regresi yang saya buat sebesar 32.16%. Ini artinya bahwa tingkat keakuratannya masih relatif rendah.
Urutan variable yang memiliki nilai prediksi paling besar adalah variable EPS dengan koefisien estimiasi sebesar 1.35134. Kemudian disusul oleh variable Sales dengan tingkat koefisien estimasi sebesar 0.13887. Sedangkan variable BV memiliki koefisien sebesar -0.01992. dapat disimpulkan bahwa variable yang paling berpengaruh terhadap stock price atau harga saham adalah variable EPS. Sedangkan variable BV tidak memiliki pengaruh terhadap stock price atau harga saham.