Solved – imputing missing values of finance data

rtime series

I have 5 years stock closing price of company almost every data with some missing values in between having 1443 data points,when i create time-series object in R with frequency 365 it creates 1834 data points.

How do I impute missing values in original data for missing values? Or is there any way in R to account for missing values and only create ts values for 1443 data points which are present?

R command used:

st_ts = ts(stocks[,2],
    start = c(2010,1),
    end = c(2015,9),
    frequency = 365)

Best Answer

One of the packages I find very useful is ImputeTS.

This package has various ways of imputation and it is very easy to use.

E.g. Spline Interpolation

st_ts_imputed   <- na.interpolation(st_ts, option = "spline")

The package file can help you with the implementation of the methods.

Other Packages to look at

missForest
VIM
Amelia
DMwR
mice
missMDA
RandomForest
yaImpute
CoImp
mix
mi
Hmisc

These are a lot of different packages and methods, but in some instance certain methods work better than other. So this is tools you can use to impute the missing values present in your data.

Related Question