Project Regresi UAS Data Analitik

Author

Viki Uswatun Khasanah_142210006_EA-B

A. Akses data/Memuat Data

Load Data Google Sheet

Memuat data google sheet berdasarkan sheet ID dan mengubah nama file untuk memudahkan dalam pengkodean

library(googlesheets4)
googlesheets4::gs4_deauth()
fdr <- read_sheet("1yLiaTItgaZfg_fSejwGJmO-rWrwbya-MZHceeVC0tK4")
✔ Reading from "Financial Data & Ratio - Q3 2022".
✔ Range 'Sheet1'.
View(fdr)

B. Penyiapan data/Data Preparation

1. Mencari Harga Saham Dan Data Preparation

Data preparation dan mencari harga saham sudah saya lakukan di google sheet dengan cara BV x PBV

2. Merubah Jenis Data

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`)

C. Visualisasi Ringkas & Pengujian Korelasi

1. Melakukan Pola Data Deengan Memvisualisasikan

1.1 Visualisasi Data Variable Independen Terhadap Stock Price

1.1.1 Memvisualisasikan korelasi variable Sales dengan 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()`).

1.1.2 Memvisualisasikan korelasi variable EPS dengan Stock Price

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'

1.1.3 Memvisualisasikan korelasi variable BV dengan Stock Price

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'

1.2 Visualisasi Data Beberapa Variable Terhadap Stock Price

1.1.1 Memvisualisasikan korelasi variable EPS, BV, Sales, dengan dependent Stock Price

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()`).

2. Pengujian Korelasi

2.1 Uji Korelasi Variable Independen Terhadap Harga Saham

2.1.1 Uji korelasi variable Sales pada Stock Price

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 

2.1.2 Uji korelasi variable EPS pada Stock Price

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 

2.1.3 Uji korelasi variable BV pada Stock Price

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 

2.1.4 Interpretasi Hasil Uji Korelasi

Dari hasil uji korelasi berikut urutan variable yang memiliki korelasi tertinggi hingga terendah terhadap Stock Price:

  1. EPS (Earning Per Share) dengan korelasi sebesar 0.4846697

  2. Sales (Price Earning Ratio) dengan korelasi sebesar 0.3521434

  3. BV (Book Value) dengan korelasi sebesar 0.3143213

1.2 Uji Korelasi Data Beberapa Variable Terhadap Stock Price

2.2.1 Uji korelasi variable PER, EPS, dan BV terhadap Stock Price

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 

2.2.2 Interpretasi hasil uji korelasi variable Sales, EPS, dan BV terhadap Stock Price

Berdasarkan hasil uji korelasi didapatka korelasi variable Sales, EPS, dan BV terhadap Stock Price sebesar 0.4615925

D. Pemodelan menggunakan Regresi

1. Membuat Model Regresi Untuk Variable Sales, EPS, dan BV terhadap Stock Price

library(moderndive)
regresi <- lm(fdr$`Stock Price`~EPS+BV+Sales, fdr)

2. Plot Regresi

plot(regresi)

E. Menampilkan hasil (termasuk merumuskan persamaan regresi yang dihasilkan dari model pada script Quarto/R Script)

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

F. Interpretasi

1. Berapa persen kemampuan prediksi model regresi yang digunakan?

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.

2. Varible mana saja yang paling berpengaruh

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.