Note that there are some explanatory texts on larger screens.

plurals
  1. PORolling correlation between zoo objects of unequal size
    primarykey
    data
    text
    <p>I have two zoo objects of unequal size (inflow and outflow). Outflow values lag inflow by some unknown amount of time. I would like to determine the correlation between the smaller outflow object (6 rows) and the larger inflow object (many rows), 6 rows at a time, starting at the inflow beginning time, incrementing by one, and find the period of highest correlation. I think this is called a "sliding window" comparison. I've tried many different ways, unsuccessfully, to use the "rollapply" function to do this but get an error because the size difference between the two objects. Hope someone will understand what I'm trying to ask and can offer a solution. Below is a portion of my data and an example of how I have tried to use the rollapply function. </p> <pre><code>&gt; inflow (03/14/13 07:00:00) 11.20451 (03/14/13 07:02:00) 11.03810 (03/14/13 07:04:00) 11.03012 (03/14/13 07:06:00) 11.09517 (03/14/13 07:08:00) 10.90878 (03/14/13 07:10:00) 11.23285 (03/14/13 07:12:00) 11.14890 (03/14/13 07:14:00) 11.17002 (03/14/13 07:16:00) 11.38342 (03/14/13 07:18:00) 11.70833 (03/14/13 07:20:00) 11.93776 (03/14/13 07:22:00) 12.17832 (03/14/13 07:24:00) 12.39648 (03/14/13 07:26:00) 12.24020 (03/14/13 07:28:00) 12.18667 (03/14/13 07:30:00) 12.45410 (03/14/13 07:32:00) 12.50012 (03/14/13 07:34:00) 12.54736 (03/14/13 07:36:00) 13.05010 (03/14/13 07:38:00) 13.06495 (03/14/13 07:40:00) 13.14084 (03/14/13 07:42:00) 12.92427 (03/14/13 07:44:00) 12.98699 (03/14/13 07:46:00) 12.84172 (03/14/13 07:48:00) 12.87263 (03/14/13 07:50:00) 12.51861 (03/14/13 07:52:00) 12.98763 (03/14/13 07:54:00) 12.31124 (03/14/13 07:56:00) 12.33696 (03/14/13 07:58:00) 12.49630 (03/14/13 08:00:00) 12.40648 (03/14/13 08:02:00) 11.87164 (03/14/13 08:04:00) 12.76058 (03/14/13 08:06:00) 12.50016 (03/14/13 08:08:00) 12.68696 (03/14/13 08:10:00) 12.88447 (03/14/13 08:12:00) 12.33336 (03/14/13 08:14:00) 13.06670 (03/14/13 08:16:00) 13.15070 (03/14/13 08:18:00) 12.82410 (03/14/13 08:20:00) 12.91953 </code></pre> <p>outflow2</p> <pre><code>(03/14/13 07:54:00) (03/14/13 07:56:00) (03/14/13 07:58:00) (03/14/13 08:00:00) (03/14/13 08:02:00) (03/14/13 08:04:00) 11.51110 11.11878 11.05775 11.11303 10.95417 10.98035 </code></pre> <p>Use:</p> <pre><code>&gt; test &lt;- rollapply(inflow, width = 6, by = 1, FUN = cor(inflow, outflow)) Error in cor(inflow, outflow) : incompatible dimensions </code></pre>
    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.
 

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