Read sample data by specifying the symbol. The two utilities, ldhmm.get_data and ldhmm.get_data.arr,
serves for slightly different purpose.
ldhmm.get_data works off the xts object that has two rows:
the prices and log-returns indexed by the dates.
ldhmm.get_data.arr and ldhmm.get_data.ts separate the data into list of three vectors: x is the log-return, p is the prices, and d is the dates.
And allows for more sophisticated call for range of dates, and different ways of slice and lag.
ldhmm.get_data.arr takes symbol as input, while ldhmm.get_data.ts takes an xts object.
ldhmm.get_data(symbol = "dji")ldhmm.get_data.arr(
symbol = "dji",
start.date = "1950-01-01",
end.date = "2015-12-31",
on = "days",
lag = 1,
drop = 0,
repeated = TRUE,
cache = TRUE,
do.kurtosis = FALSE
)
ldhmm.get_data.ts(
ts,
start.date = "1950-01-01",
end.date = "2015-12-31",
on = "days",
lag = 1,
drop = 0,
repeated = TRUE,
do.kurtosis = FALSE
)
ldhmm.get_data returns an xts object for the time series, with two columns - "Close" and "logr".
ldhmm.get_data.arr and ldhmm.get_data.ts return a list of three vectors: x is the log-return, p is the prices, and d is the dates.
character, the symbol of the time series. Default: dji
Date or character of ISO format (YYYY-MM-DD), to specify the date range, default is from 1950-01-01 to 2015-12-31. Set start.date and end.date to NULL or "" if you wish to get the entire time series.
character, specify the calendar interval, days, weeks, months. Default is days.
integer, specify the lags of return calculation, default is 1.
integer, specify number of largest outliners to drop, default is 0.
logical, specify whether to use repeated sampling or unique sampling, default is TRUE.
Using "repeated" sampling can reduce noise due to insufficient sample size. This is particularly useful for larger lags.
logical, use R's options memory to cache xts data, default is TRUE.
logical, if specified, calculate mean, sd, var, skewness, and kurtosis, default is FALSE.
xts, the time series
dji <- ldhmm.get_data()
wti <- ldhmm.get_data("wti")
spx <- ldhmm.get_data.arr("spx", lag=5)
Run the code above in your browser using DataLab