[R-SIG-Finance] in xts behavior of to.minutes() and to.period()
Kenneth Spriggs
ksspriggs at gmail.com
Wed Jun 24 17:47:32 CEST 2009
Thanks. That makes sense. I guess I should've taken the Warning more
seriously:
Warning messages:
1: In to.period(x, "minutes", k = k, name = name, ...) :
missing values removed from data
: In to.period(WMP, period = "minutes", k = 2) :
missing values removed from data
On Wed, Jun 24, 2009 at 10:35 AM, J Ryan<jeff.a.ryan at gmail.com> wrote:
> That is reasonable.
>
> You are missing observations *within* the 2 minutes. Somewhere entire minute
> blocks are missing in the raw data, and there is no bar to calculate
>
> You'll have to merge again the results to make the index consistent.
>
> HTH
> Jeff
>
>
> Jeffrey A. Ryan
> jeffrey.ryan at insightalgo.com
>
> ia: insight algorithmics
> www.insightalgo.com
>
> On Jun 24, 2009, at 10:30 AM, Kenneth Spriggs <ksspriggs at gmail.com> wrote:
>
>> Oh yeah, oops but it still isn't adding up...
>>
>>> sum(is.na(VI))
>>
>> [1] 0
>>
>>> sum(is.na(WMP))
>>
>> [1] 1973
>>
>>
>>
>> On Wed, Jun 24, 2009 at 10:27 AM, Joshua Ulrich<josh.m.ulrich at gmail.com>
>> wrote:
>>>
>>> That won't provide the result you're looking for. It is testing if
>>> the result of is.na() is a character string, so it will always be
>>> FALSE because is.na() returns logical values (either TRUE or FALSE, no
>>> quotes). Try this instead:
>>>
>>> nrow(is.na(VI) == FALSE)
>>> or
>>> sum(is.na(VI))
>>>
>>> The results of head()/tail() in your previous email show that WMP has
>>> at least one NA value.
>>>
>>> Best,
>>> Josh
>>> --
>>> http://www.fosstrading.com
>>>
>>>
>>>
>>> On Wed, Jun 24, 2009 at 10:22 AM, Kenneth Spriggs<ksspriggs at gmail.com>
>>> wrote:
>>>>
>>>> Hi Josh,
>>>>
>>>>> nrow(is.na(VI) == 'FALSE')
>>>>
>>>> [1] 401600
>>>>
>>>>> nrow(is.na(WMP) == 'FALSE')
>>>>
>>>> [1] 401600
>>>>
>>>>>
>>>>
>>>>
>>>> On Wed, Jun 24, 2009 at 10:02 AM, Joshua Ulrich
>>>> <josh.m.ulrich at gmail.com>
>>>> wrote:
>>>>>
>>>>> Hi Kenneth,
>>>>>
>>>>> to.period() removes NAs before aggregating. So I would guess WMP has
>>>>> 4 rows with NA, and those same values in VI are zero.
>>>>>
>>>>> HTH,
>>>>> Josh
>>>>> --
>>>>> http://www.fosstrading.com
>>>>>
>>>>>
>>>>>
>>>>> On Wed, Jun 24, 2009 at 9:52 AM, Kenneth Spriggs<ksspriggs at gmail.com>
>>>>> wrote:
>>>>>>
>>>>>> Both VI and WMP are derived from the same xts object - they have the
>>>>>> same rows. When I use to.minutes() on VI it yields 618 rows but for
>>>>>> WMP it yields 614 rows.
>>>>>> (Same thing if I use to.period() but that's not surprising.) You can
>>>>>> see both the start times and end times are the same...
>>>>>>
>>>>>>> nrow(VI); nrow(WMP)
>>>>>>
>>>>>> [1] 401600
>>>>>> [1] 401600
>>>>>>
>>>>>>> head(VI, 1); tail(VI, 1)
>>>>>>
>>>>>> LastPrice
>>>>>> 2009-06-22 21:41:54.869 0
>>>>>> LastPrice
>>>>>> 2009-06-23 18:59:59.735 25689
>>>>>>
>>>>>>> head(WMP, 1); tail(WMP, 1)
>>>>>>
>>>>>> BidPrice
>>>>>> 2009-06-22 21:41:54.869 NA
>>>>>> BidPrice
>>>>>> 2009-06-23 18:59:59.735 115.4746
>>>>>>
>>>>>>> VI_minute2 <- to.minutes(VI,2)
>>>>>>> WMP_minute2 <- to.minutes(WMP, 2)
>>>>>>> nrow(VI_minute2); nrow(WMP_minute2)
>>>>>>
>>>>>> [1] 618
>>>>>> [1] 614
>>>>>>
>>>>>>> VI_minute2p <- to.period(VI, period = "minutes", k=2)
>>>>>>> WMP_minute2p <- to.period(WMP, period = "minutes", k=2)
>>>>>>> nrow(VI_minute2p); nrow(WMP_minute2p)
>>>>>>
>>>>>> [1] 618
>>>>>> [1] 614
>>>>>>
>>>>>> _______________________________________________
>>>>>> R-SIG-Finance at stat.math.ethz.ch mailing list
>>>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>>>>>> -- Subscriber-posting only.
>>>>>> -- If you want to post, subscribe first.
>>>>>>
>>>>
>>>>
>>>
>>
>> _______________________________________________
>> R-SIG-Finance at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> -- Subscriber-posting only.
>> -- If you want to post, subscribe first.
>
More information about the R-SIG-Finance
mailing list