Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Use a data frame or an xts object. They both cope well with varying numbers of columns. In your case, as all your data columns are numeric type, you can use the xts object.</p> <p>You said "rolling" in your title. Did you mean you want to analyze 90 day overlapping periods? E.g. 2008-01-02 to 2008-04-02, then 2008-01-03 to 2008-04-03, and so on? If so <code>rollapply(data,width=90,FUN)</code> can be used. If you wanted to deal with quarters, one at a time, <code>quarters &lt;- split(data,'quarters')</code> and then (as that gives you a list of xts objects) <code>lapply(quarters,FUN)</code></p> <p>I think your issue with using a single data structure was that SMA5 is available from 2008-01-08, but that SMA200 is not available until almost the end of the year; meaning that in the first three quarters the SMA200 column will contain nothing but NAs? This is fine. Keep the NAs and deal with them just before you pass the data to RandomForest.</p> <p>In FUN you will remove the columns that contain NA like this (where <code>xq</code> is an xts object containing data for just one quarter):</p> <pre><code>xq = xq[,!apply(is.na(x),2,any)] </code></pre> <p><strong>UPDATE:</strong> After re-reading your question, and your follow-up question I think the above answers the question you didn't have! I thought the issue was having NAs in your TTR table, and that RandomForest does not like them.</p> <p>On reflection, I think your actual question was "The RandomForest gives me a varying number of good indicators from its analysis of each quarter, how do I deal with that?" The answer is a ragged data structure, a list. One list entry per quarter. The list entry itself can be anything, even an xts object, but in this case a simple character vector of indicators names seems to be perfect. This is shown nicely in <a href="https://stackoverflow.com/a/12607702/841830">Zach's answer</a> to your other question.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload