I am new to R and need to use the function getnfac from the PANICr package. And it seems that the function only takes an xts object as its first argument. However, after I went through some reading I still don't understand what an xts object is. Could anyone please tell me how I can convert a matrix into an xts object?
Below I use return matrix as the first argument. Therefore I just need to convert return to an xts object.
getnfac(return,143,"BIC3")
Error in getnfac(return, 143, "BIC3") :
x must be an xts object so lags and differences are taken properly
xtsis an extensible time series object, essentially a regulartsobject (or more correctly azooobject) with some bits added.The 'extensible' part of the name refers to how you can add attributes of your own choice.
While a
matrixcan be converted into a multivariate time series quite easilyAn
xtsrequires its index (a vector describing at what time each sample was taken) to be in a date or time formatIf your data is sampled at evenly spaced intervals a dummy index like the one above is probably ok. If not, you'll need to supply a vector corresponding to the sampling times.