## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.1 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ 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
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
##
## ── Attaching core tidyquant packages ──────────────────────── tidyquant 1.0.9 ──
## ✔ PerformanceAnalytics 2.0.4 ✔ TTR 0.24.4
## ✔ quantmod 0.4.26 ✔ xts 0.14.0
## ── Conflicts ────────────────────────────────────────── tidyquant_conflicts() ──
## ✖ zoo::as.Date() masks base::as.Date()
## ✖ zoo::as.Date.numeric() masks base::as.Date.numeric()
## ✖ dplyr::filter() masks stats::filter()
## ✖ xts::first() masks dplyr::first()
## ✖ dplyr::lag() masks stats::lag()
## ✖ xts::last() masks dplyr::last()
## ✖ PerformanceAnalytics::legend() masks graphics::legend()
## ✖ quantmod::summary() masks base::summary()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
1 Get stock prices and convert to returns
## # A tibble: 27 × 3
## # Groups: symbol [3]
## symbol date Ra
## <chr> <date> <dbl>
## 1 AMZN 2024-01-31 0.0351
## 2 AMZN 2024-02-29 0.139
## 3 AMZN 2024-03-28 0.0205
## 4 AMZN 2024-04-30 -0.0298
## 5 AMZN 2024-05-31 0.00823
## 6 AMZN 2024-06-28 0.0953
## 7 AMZN 2024-07-31 -0.0324
## 8 AMZN 2024-08-30 -0.0454
## 9 AMZN 2024-09-23 0.0862
## 10 RGR 2024-01-31 -0.0309
## # ℹ 17 more rows
2 Get baseline and convert to returns
## # A tibble: 9 × 2
## date Rb
## <date> <dbl>
## 1 2024-01-31 0.0270
## 2 2024-02-29 0.0612
## 3 2024-03-28 0.0179
## 4 2024-04-30 -0.0441
## 5 2024-05-31 0.0688
## 6 2024-06-28 0.0596
## 7 2024-07-31 -0.00751
## 8 2024-08-30 0.00649
## 9 2024-09-23 0.0147
3 Join the two tables
## # A tibble: 27 × 4
## # Groups: symbol [3]
## symbol date Ra Rb
## <chr> <date> <dbl> <dbl>
## 1 AMZN 2024-01-31 0.0351 0.0270
## 2 AMZN 2024-02-29 0.139 0.0612
## 3 AMZN 2024-03-28 0.0205 0.0179
## 4 AMZN 2024-04-30 -0.0298 -0.0441
## 5 AMZN 2024-05-31 0.00823 0.0688
## 6 AMZN 2024-06-28 0.0953 0.0596
## 7 AMZN 2024-07-31 -0.0324 -0.00751
## 8 AMZN 2024-08-30 -0.0454 0.00649
## 9 AMZN 2024-09-23 0.0862 0.0147
## 10 RGR 2024-01-31 -0.0309 0.0270
## # ℹ 17 more rows
4 Calculate CAPM
## # A tibble: 3 × 2
## # Groups: symbol [3]
## symbol skewness.1
## <chr> <dbl>
## 1 AMZN 0.389
## 2 RGR 0.621
## 3 WMT 0.621
which stock/s has a positively skewed distribution of returns?
All three stocks were all positively skewed