Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create new introduction chapters #145

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
17 changes: 17 additions & 0 deletions _freeze/r/capital-asset-pricing-model/execute-results/html.json

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions _freeze/r/discounted-cash-flow-analysis/execute-results/html.json

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions _freeze/r/financial-ratios/execute-results/html.json

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions _freeze/r/modern-portfolio-theory/execute-results/html.json

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions _freeze/r/working-with-stock-returns/execute-results/html.json

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion _quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ website:
contents:
- r/setting-up-your-environment.qmd
- r/the-tidyfinance-r-package.qmd
- r/introduction-to-tidy-finance.qmd
- r/working-with-stock-returns.qmd
- r/modern-portfolio-theory.qmd
- r/capital-asset-pricing-model.qmd
- r/financial-ratios.qmd
- r/discounted-cash-flow-analysis.qmd
- section: "Financial Data"
contents:
- r/accessing-and-managing-financial-data.qmd
Expand Down
7 changes: 7 additions & 0 deletions assets/bib/packages-r.bib
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ @book{ggplot2
note = {R package version 3.3.6},
isbn = {978-3-319-24277-4},
}
@manual{@ggrepel,
title = {ggrepel: Automatically Position Non-Overlapping Text Labels with 'ggplot2'},
author = {Kamil Slowikowski},
year = {2024},
url = {https://ggrepel.slowkow.com/},
note = {R package version 0.9.6},
}
@article{glmnet,
title = {{Regularization paths for Cox's proportional hazards model via coordinate descent}},
author = {Noah Simon and Jerome Friedman and Trevor Hastie and Rob Tibshirani},
Expand Down
48 changes: 48 additions & 0 deletions assets/img/assets.svg

Large diffs are not rendered by default.

Binary file added assets/img/balance-sheet-msft.png
24 changes: 24 additions & 0 deletions assets/img/balance-sheet.svg

Large diffs are not rendered by default.

Binary file added assets/img/cash-flow-statements-msft.png
115 changes: 115 additions & 0 deletions assets/img/cash-flow-statements.svg

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions assets/img/equity.svg

Large diffs are not rendered by default.

Binary file added assets/img/income-statements-msft.png
55 changes: 55 additions & 0 deletions assets/img/income-statements.svg

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions assets/img/liabilities.svg

Large diffs are not rendered by default.

Binary file added assets/img/stockholders-equity-msft.png
48 changes: 48 additions & 0 deletions docs/assets/img/assets.svg

Large diffs are not rendered by default.

Binary file added docs/assets/img/balance-sheet-msft.png
24 changes: 24 additions & 0 deletions docs/assets/img/balance-sheet.svg

Large diffs are not rendered by default.

Binary file added docs/assets/img/cash-flow-statements-msft.png
115 changes: 115 additions & 0 deletions docs/assets/img/cash-flow-statements.svg

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions docs/assets/img/equity.svg

Large diffs are not rendered by default.

Binary file added docs/assets/img/income-statements-msft.png
55 changes: 55 additions & 0 deletions docs/assets/img/income-statements.svg

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions docs/assets/img/liabilities.svg

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/introduction-to-tidy-finance.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<head>
<title>Redirect</title>
<script type="text/javascript">
var redirects = {"":"r/introduction-to-tidy-finance.html"};
var redirects = {"":"r/working-with-stock-returns.html"};
var hash = window.location.hash.startsWith('#') ? window.location.hash.slice(1) : window.location.hash;
var redirect = redirects[hash] || redirects[""] || "/";
window.document.title = 'Redirect to ' + redirect;
Expand Down
10 changes: 5 additions & 5 deletions docs/python/factor-selection-via-machine-learning.html
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ <h2 class="anchored" data-anchor-id="data-preparation">Data Preparation</h2>
<span id="cb4-8"><a href="#cb4-8" aria-hidden="true" tabindex="-1"></a>)</span>
<span id="cb4-9"><a href="#cb4-9" aria-hidden="true" tabindex="-1"></a>data_plot.draw()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="6">
<div id="fig-1401" class="quarto-float quarto-figure quarto-figure-center anchored" alt="Title: Excess return distributions by industry in percent. The figure shows boxplots that visualize the industry's excess return distribution. All industry returns are centered around zero and exhibit substantial outliers in the magnitude of 20 percent on a monthly basis." data-fig-pos="htb">
<div id="fig-1401" class="quarto-float quarto-figure quarto-figure-center anchored" data-fig-pos="htb" alt="Title: Excess return distributions by industry in percent. The figure shows boxplots that visualize the industry's excess return distribution. All industry returns are centered around zero and exhibit substantial outliers in the magnitude of 20 percent on a monthly basis.">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-1401-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<a href="factor-selection-via-machine-learning_files/figure-html/fig-1401-output-1.png" class="lightbox" data-gallery="quarto-lightbox-gallery-1" title="Figure&nbsp;1: The box plots show the monthly dispersion of returns for 10 different industries."><img src="factor-selection-via-machine-learning_files/figure-html/fig-1401-output-1.png" data-fig-pos="htb" alt="Title: Excess return distributions by industry in percent. The figure shows boxplots that visualize the industry's excess return distribution. All industry returns are centered around zero and exhibit substantial outliers in the magnitude of 20 percent on a monthly basis." width="647" height="407" class="figure-img"></a>
Expand Down Expand Up @@ -821,7 +821,7 @@ <h3 class="anchored" data-anchor-id="fit-a-model">Fit a model</h3>
<span id="cb8-26"><a href="#cb8-26" aria-hidden="true" tabindex="-1"></a>)</span>
<span id="cb8-27"><a href="#cb8-27" aria-hidden="true" tabindex="-1"></a>predicted_values_plot.draw()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="10">
<div id="fig-1402" class="quarto-float quarto-figure quarto-figure-center anchored" alt="Title: Monthly realized and fitted manufacturing industry risk premium. The figure shows the time series of realized and predicted manufacturing industry risk premiums. The figure seems to indicate that the predictions capture most of the return dynamics." data-fig-pos="htb">
<div id="fig-1402" class="quarto-float quarto-figure quarto-figure-center anchored" data-fig-pos="htb" alt="Title: Monthly realized and fitted manufacturing industry risk premium. The figure shows the time series of realized and predicted manufacturing industry risk premiums. The figure seems to indicate that the predictions capture most of the return dynamics.">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-1402-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<a href="factor-selection-via-machine-learning_files/figure-html/fig-1402-output-1.png" class="lightbox" data-gallery="quarto-lightbox-gallery-2" title="Figure&nbsp;2: The figure shows monthly realized and fitted manufacturing industry risk premium. The grey area corresponds to the out of sample period."><img src="factor-selection-via-machine-learning_files/figure-html/fig-1402-output-1.png" data-fig-pos="htb" alt="Title: Monthly realized and fitted manufacturing industry risk premium. The figure shows the time series of realized and predicted manufacturing industry risk premiums. The figure seems to indicate that the predictions capture most of the return dynamics." width="647" height="407" class="figure-img"></a>
Expand Down Expand Up @@ -873,7 +873,7 @@ <h3 class="anchored" data-anchor-id="fit-a-model">Fit a model</h3>
<span id="cb10-9"><a href="#cb10-9" aria-hidden="true" tabindex="-1"></a> theme(legend_position<span class="op">=</span><span class="st">"none"</span>))</span>
<span id="cb10-10"><a href="#cb10-10" aria-hidden="true" tabindex="-1"></a>coefficients_plot.draw()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="12">
<div id="fig-1403" class="quarto-float quarto-figure quarto-figure-center anchored" alt="Title: Estimated coefficient paths for different penalty factors. The figure shows how estimated lasso and ridge coefficients tend to zero for a higher penalty parameter. Ridge trace is smooth, and Lasso exhibits non-linear behavior." data-fig-pos="htb">
<div id="fig-1403" class="quarto-float quarto-figure quarto-figure-center anchored" data-fig-pos="htb" alt="Title: Estimated coefficient paths for different penalty factors. The figure shows how estimated lasso and ridge coefficients tend to zero for a higher penalty parameter. Ridge trace is smooth, and Lasso exhibits non-linear behavior.">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-1403-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<a href="factor-selection-via-machine-learning_files/figure-html/fig-1403-output-1.png" class="lightbox" data-gallery="quarto-lightbox-gallery-3" title="Figure&nbsp;3: The figure shows estimated coefficient paths for different penalty factors. The penalty parameters are chosen iteratively to resemble the path from no penalization to a model that excludes all variables."><img src="factor-selection-via-machine-learning_files/figure-html/fig-1403-output-1.png" data-fig-pos="htb" alt="Title: Estimated coefficient paths for different penalty factors. The figure shows how estimated lasso and ridge coefficients tend to zero for a higher penalty parameter. Ridge trace is smooth, and Lasso exhibits non-linear behavior." width="647" height="407" class="figure-img"></a>
Expand Down Expand Up @@ -958,7 +958,7 @@ <h3 class="anchored" data-anchor-id="tune-a-model">Tune a model</h3>
<span id="cb12-23"><a href="#cb12-23" aria-hidden="true" tabindex="-1"></a>)</span>
<span id="cb12-24"><a href="#cb12-24" aria-hidden="true" tabindex="-1"></a>validation_plot.draw()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="14">
<div id="fig-1404" class="quarto-float quarto-figure quarto-figure-center anchored" alt="Title: Root MSPE for different penalty factors. The figure shows that more regularization does not affect the selected models in a meaningful fashion. At some point, the Elastic Net prediction error drops, which indicates the selected model. MSPE increases again for high penalization values." data-fig-pos="htb">
<div id="fig-1404" class="quarto-float quarto-figure quarto-figure-center anchored" data-fig-pos="htb" alt="Title: Root MSPE for different penalty factors. The figure shows that more regularization does not affect the selected models in a meaningful fashion. At some point, the Elastic Net prediction error drops, which indicates the selected model. MSPE increases again for high penalization values.">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-1404-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<a href="factor-selection-via-machine-learning_files/figure-html/fig-1404-output-1.png" class="lightbox" data-gallery="quarto-lightbox-gallery-4" title="Figure&nbsp;4: The figure shows root MSPE for different penalty factors. Evaluation of manufacturing excess returns for different penalty factors (lambda) and proportions of Lasso penalty (rho). 1.0 indicates Lasso, 0.5 indicates Elastic Net, and 0.0 indicates Ridge."><img src="factor-selection-via-machine-learning_files/figure-html/fig-1404-output-1.png" data-fig-pos="htb" alt="Title: Root MSPE for different penalty factors. The figure shows that more regularization does not affect the selected models in a meaningful fashion. At some point, the Elastic Net prediction error drops, which indicates the selected model. MSPE increases again for high penalization values." width="647" height="407" class="figure-img"></a>
Expand Down Expand Up @@ -1036,7 +1036,7 @@ <h3 class="anchored" data-anchor-id="full-workflow">Full workflow</h3>
<span id="cb15-11"><a href="#cb15-11" aria-hidden="true" tabindex="-1"></a>)</span>
<span id="cb15-12"><a href="#cb15-12" aria-hidden="true" tabindex="-1"></a>selected_factors_plot.draw()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="17">
<div id="fig-1405" class="quarto-float quarto-figure quarto-figure-center anchored" alt="Title: Selected variables for different industries. The figure shows which factors and macroeconomic predictors the Lasso model selected for the different industries. In general, there are not many selected variables. The market excess return is selected across all industries except for utilities." data-fig-pos="htb">
<div id="fig-1405" class="quarto-float quarto-figure quarto-figure-center anchored" data-fig-pos="htb" alt="Title: Selected variables for different industries. The figure shows which factors and macroeconomic predictors the Lasso model selected for the different industries. In general, there are not many selected variables. The market excess return is selected across all industries except for utilities.">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-1405-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<a href="factor-selection-via-machine-learning_files/figure-html/fig-1405-output-1.png" class="lightbox" data-gallery="quarto-lightbox-gallery-5" title="Figure&nbsp;5: The figure shows selected variables for different industries. Dark areas indicate that the estimated Lasso regression coefficient is not set to zero. White fields show which variables get assigned a value of exactly zero."><img src="factor-selection-via-machine-learning_files/figure-html/fig-1405-output-1.png" data-fig-pos="htb" alt="Title: Selected variables for different industries. The figure shows which factors and macroeconomic predictors the Lasso model selected for the different industries. In general, there are not many selected variables. The market excess return is selected across all industries except for utilities." width="647" height="647" class="figure-img"></a>
Expand Down
Loading