- Financial Time Series Data
- Exploring Time Series Data in R
- Plotting Time Series in R
- Handling Missing Values in Time Series
- Creating a Time Series Object in R
- Check if an object is a time series object in R
- Plotting Financial Time Series Data (Multiple Columns) in R
- Characteristics of Time Series
- Stationary Process in Time Series
- Transforming a Series to Stationary
- Time Series Transformation in R
- Differencing and Log Transformation
- Autocorrelation in R
- Time Series Models
- ARIMA Modeling
- Simulate White Noise (WN) in R
- Simulate Random Walk (RW) in R
- AutoRegressive (AR) Model in R
- Estimating AutoRegressive (AR) Model in R
- Forecasting with AutoRegressive (AR) Model in R
- Moving Average (MA) Model in R
- Estimating Moving Average (MA) Model in R
- ARIMA Modelling in R
- ARIMA Modelling - Identify Model for a Time Series
- Forecasting with ARIMA Modeling in R - Case Study
- Automatic Identification of Model Using auto.arima() Function in R
- Financial Time Series in R - Course Conclusion
Differencing and Log Transformation
Removing Variability Using Logarithmic Transformation
Since the data shows changing variance over time, the first thing we will do is stabilize the variance by applying log transformation using the log()
function. The resulting series will be a linear time series.
> sp_linear<-log(sp_ts)
> plot.ts(sp_linear, main="Daily Stock Prices (log)", ylab="Price", col=4)
Removing Linear Trend
We will now perform the first difference transformation [z(t) - z(t-1)]
to our series to remove the linear trend.
> sp_linear_diff <- diff(sp_linear)
> plot.ts(sp_linear_diff, main="Daily Stock Prices (log)", ylab="Price", col=4)
>
Removing Seasonal Differencing
Let's take another example to understand how we can use the diff()
function to remove seasonal differencing from data. We will use the John Deer's Quarterly earnings data we used earlier as it exhibits seasonality.
> par(mfrow = c(1,2))
> de_earnings_diff <- diff(johndeere_earnings,lag=4)
> plot.ts(johndeere_earnings, main="Earnings (Quarterly)")
> plot.ts(de_earnings_diff, main="Earnings (Differenced, lag=4)")
The chart on the left shows the original earnings. The chart on the right shows the difference in earnings with a lag of 4.
Related Downloads
Data Science in Finance: 9-Book Bundle
Master R and Python for financial data science with our comprehensive bundle of 9 ebooks.
What's Included:
- Getting Started with R
- R Programming for Data Science
- Data Visualization with R
- Financial Time Series Analysis with R
- Quantitative Trading Strategies with R
- Derivatives with R
- Credit Risk Modelling With R
- Python for Data Science
- Machine Learning in Finance using Python
Each book includes PDFs, explanations, instructions, data files, and R code for all examples.
Get the Bundle for $29 (Regular $57)Free Guides - Getting Started with R and Python
Enter your name and email address below and we will email you the guides for R programming and Python.