ldhmm.get_data {ldhmm} | R Documentation |
Read sample data
Description
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.
Usage
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
)
Arguments
symbol |
character, the symbol of the time series. Default: dji |
start.date , end.date |
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. |
on |
character, specify the calendar interval, days, weeks, months. Default is |
lag |
integer, specify the lags of return calculation, default is 1. |
drop |
integer, specify number of largest outliners to drop, default is 0. |
repeated |
logical, specify whether to use repeated sampling or unique sampling, default is |
cache |
logical, use R's options memory to cache xts data, default is |
do.kurtosis |
logical, if specified, calculate mean, sd, var, skewness, and kurtosis, default is |
ts |
xts, the time series |
Value
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.
Examples
dji <- ldhmm.get_data()
wti <- ldhmm.get_data("wti")
spx <- ldhmm.get_data.arr("spx", lag=5)