Welcome to this course on financial time series analysis using R. In this course, we will learn about financial time series data analysis in R. You will learn about how to explore and build time series data, calculate its key statistics, and plot time series charts. You will also learn about how to use the […]

# Financial Time Series Analysis in R

## Exploring Time Series Data in R

Let’s look at a few commands that we will frequently use while exploring time series data. length() The length() function tells us the number of elements in out time series dataset. head() The head() function displays the top n elements of the dataset. This is useful while exploring large datasets. tail() The tail() function displays the last n elements of the […]

## Plotting Time Series in R

While we can explore time series data using commands such as print(), head(), tail(), etc in R, it can be very helpful to plot the time series data as a line chart and explore it visually. In the following examples, we plot the Microsoft stock data and the quarterly GDP data in two different plots using the plot() function in […]

## Handling Missing Values in Time Series

In the examples we saw earlier, we had good quality data with all values available for all time indexes. However, in real life, the data may contain missing values which will influence our analysis. Depending on the nature of data, we may choose to ignore missing values. However, in some cases it might be more […]

## Creating a Time Series Object in R

In R, we can use the ts() function to create a time series object. Usage Below is a simplified format of the ts function. For complete details use ?ts in your R console. data: a vector or matrix of the observed time-series values. start: the time of the first observation. end: the time of the last observation, specified in the same way as start. […]

## Check if an object is a time series object in R

In R, objects can be of different class such as vector, list, dataframe, ts, etc. When you load a dataset into R, it may not necessarily be a time series object. We can use the is.ts() function to test if the given object is a time series (ts) object or not. Below we perform this test on […]

## Plotting Financial Time Series Data (Multiple Columns) in R

Let’s take one more example of plotting financial time series data. This time we will use the EuStockMarkets data set that comes by default with R. It contains the daily closing prices of major European stock indices from 1991 to 1998. Check and Print the Data Let’s first check if the data is a time series and […]

## Characteristics of Time Series

Time series have several characteristics that make their analysis different from other types of data. The time series variable (for example, the stock price) may have a trend over time. This refers to the increasing or decreasing values in a given time series. The variable may exhibit cyclicity or seasonality. This refers to the repeating cycle over a […]

## Stationary Process in Time Series

A common assumption made in time series analysis is that one of the components of the pattern exhibited by a time series is the stationary series. This is the random or irregular component we discussed earlier. This random variation is not explained by any other factor. There are three characteristics of a stationary series: It […]

## Transforming a Series to Stationary

Most financial and economic times series are not stationary. Even when you adjust them for seasonal variations, they will exhibit trends, cycles, random walk and other non-stationary behavior. We can use a variety of techniques to make a non-stationary series stationary depending on the kind of non-stationary behavior present in the series. The two techniques […]