Brent Morrison's blog

Nested time series data frames

Data leakage can be tricky when analysing time series. Ensuring you are not using the future to predict the future is very important if you want to use the past to predict the future! After all, you don’t get to use future data when you are in the present! These earthquake researchers have been accused of mixing things up. Let’s say we want to apply a machine learning algorithm that requires hyper-parameter tuning, and hence a validation data set, to a time series.

Time Series Cross-validation in Python

The content below is a Jupyter Notebook converted to markdown following the instructions of this blog. This allows for publishing of Jupyter Notebook’s using blogdown. Everything appears to work except for the rendering of tables. That will be something to resolve. Table formatting notwithstanding, it doesn’t really look as nice as the standard Jupyter Notebook format. I’ve therefore linked the original here. Introduction This notebook will implement a rolling out of sample forecast on time series data.

IFRS9 disclosures (part 2)

This post is a continuation of the series initiated here. Recall our problem imagines we are a bank lending to the largest 1,000 US companies. We (“Bank1000”) own the debt of these companies and are required to prepare IFRS9 disclosures. This requires the estimation of an expected credit loss (“ECL”) and risk stage. We have already selected the top 1,000 stocks for analysis, we now need to create an ECL balance and assign a risk stage.

Dataquest project - Python basics

I’ve recently started the Dataquest - Data Scientist In Python course. This is an interactive course and requires the completion of guided projects. The first section of the course is called “Python Introduction”. Here is the guided project associated with this on github. In the event that this does not load, apparently quite a regular occurance, here it is via Jupyter’s nbviewer. Thoughts On reflection, the requirements of this project seemed a little superficial.

IFRS9 disclosures (part 1)

This series of posts will deal with the preparation of International Financial Reporting Standard 9 - Financial Instruments (“IFRS9”) disclosures for a bank. In particular, the reconciliation tables that are required to account for movements in loan balances and expected credit losses over a reporting period. This is a somewhat arcane topic. Why do we want to do this? IFRS9 is a relatively new accounting standard and the reconciliation tables disclose a flow of loan balances over time, accounting for draw downs, repayments and other cash flows.

Time series segmentation and plotting

This post documents an exploratory data analysis that assesses the relationship between the slope of the yield curve and the S&P 500 index. We will discretise the yield curve into equal frequency bins based on its level and change and draw a histogram of the subsequent S&P 500 returns associated with each bin. We will also prepare a plot visualising periods when future S&P 500 returns are within specific parameters.

Kable correction

Lets try and resolve the issue I reported here . This code attempts to rectify the formatting issue by closing off the code chunk appropriately. I’ve also loaded the tidyverse packages as was done in this stackoverflow post. library(kableExtra) library(tidyverse) library(knitr) dt <- mtcars[1:15, 1:6] kable(dt, format = "html", align = "c") %>% kable_styling(bootstrap_options = c("striped", "hover"), full_width = T, position = "left") %>% column_spec(1, width = "10em") %>% column_spec(2, width = "7em") %>% column_spec(3, width = "7em") %>% column_spec(4, width = "7em") %>% column_spec(5, width = "7em") %>% column_spec(6, width = "7em") %>% footnote(general = "Here is a general comments of the table.

Financial data aggregator

This post will document an R script that will download and aggregate various financial and economic time series. This data will be used in future posts for modelling and analysis activities. Packages required and download parameters Load the required packages. library("DescTools") library("tidyquant") library("timetk") library("broom") library("tibbletime") Then we set parameters that determine the data to download. # Parameters for binary market indicator lb = 6 # Lookback period for drawdown assessment pc = 0.

Test post 1

This is a test post Here are some bullet points: Bullet point Table Code from the kableExtra package copied straight from this vignette library(kableExtra) library(knitr) dt <- mtcars[1:5, 1:6] kable(dt, format = "html", align = "c") %>% kable_styling(bootstrap_options = c("striped", "hover"), full_width = T,position = "left") %>% column_spec(1, width = "10em") %>% column_spec(2, width = "7em") %>% column_spec(3, width = "7em") %>% column_spec(4, width = "7em") %>% column_spec(5, width = "7em") %>% column_spec(6, width = "7em") %>% footnote(general = "Here is a general comments of the table.