Labs
Hands-on time series analysis in R
The lectures argue; the labs make you do it. Each one is a complete Quarto document — open the .qmd, run it chunk by chunk, then change something and see what breaks. Data comes from the data/ folder or is pulled live from SBP, PBS, Yahoo Finance and the World Bank.
New to R?
Start here before the method labs. These four sessions take you from installing R to writing tidyverse pipelines confidently.
R 1Learn the basics of R Installation, the Positron/RStudio interface, objects, vectors and your first plot. R 2R fundamentals, extended Data types, subsetting, functions and reading files of every awkward format. R 3Tidyverse, day one filter, select, mutate, group_by and summarise — the five verbs that do most of the work. R 4Tidyverse in action A full analysis end to end: import, tidy, model, visualise, communicate.
Method labs
Lab 1Forecasting in R tsibbles, benchmark methods, ETS and automatic ARIMA with the fable workflow. Lab 2Spurious regression by simulation Generate two independent random walks a thousand times and watch the t-statistics lie. Lab 3ARDL models in R Bounds testing and error correction estimation on Pakistani macro data. Lab 4ARDL: the Denmark money demand case The classic Johansen dataset, worked through the ARDL route for comparison. Lab 5Estimating a consumption function Econometric modelling from first principles on Pakistani consumption and income. Lab 6Forecasting with Prophet An additive alternative to ARIMA — where it helps, and where it quietly misleads. Lab 7KSE-100 index analysis Returns, volatility and interactive time series plots of the Pakistan Stock Exchange. Lab 8The USD/PKR exchange rate Daily exchange rate data: dates, irregular frequencies, and what a break looks like. Lab 9Stationarity tutorial A short guided drill on diagnosing and correcting non-stationarity. Lab 10Forecasting cement demand Seasonality, trend and a real production planning question for a Pakistani industry.
Applied case studies that go beyond the teaching sequence — remittances, exports, tax revenue, solar prices — live in the applications/ folder of the repository.