[R-SIG-Finance] Problem with stoch

Joshua Ulrich josh.m.ulrich at gmail.com
Tue Aug 30 05:22:33 CEST 2011


Hi Worik,

On Sun, Aug 28, 2011 at 11:42 PM, Worik Stanton <worik.stanton at gmail.com> wrote:
> I was getting an error "Error in runSum(x, n) : Series contains non-leading
> NAs" using stoch on an XTS with over 86,000 rows.
>
> There are no NAs in the series.
>
> Using binary search I narrowed the problem down to a section of the XTS with
> only 51 rows.  Herein.
>
> I am not concerned, as I am not really interested in stoch right now, but it
> is an interesting thing.
>

The default value of nFastK=14.  The last 20 observations of your data
all have the same value.  This means the Fast%K calculation results in
division by zero.  That's where the "non-leading NAs" originate.
Thanks for providing the data; it made the issue easy to spot.

I'm not sure this is a bug.  It seems more likely that the default
argument values for the stoch function aren't suitable for your data.
I'm open to other opinions though.

Best,
--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com



>> stoch(F)
> Error in runSum(x, n) : Series contains non-leading NAs
>> F
>                     S1.3600
> 2011-08-26 06:47:22 1.029176
> 2011-08-26 06:47:22 1.029176
> 2011-08-26 06:47:23 1.029176
> 2011-08-26 06:47:24 1.029176
> 2011-08-26 06:47:24 1.029176
> 2011-08-26 06:47:25 1.029176
> 2011-08-26 06:47:26 1.029176
> 2011-08-26 06:47:27 1.029176
> 2011-08-26 06:47:28 1.029177
> 2011-08-26 06:47:29 1.029177
> 2011-08-26 06:47:30 1.029177
> 2011-08-26 06:47:30 1.029177
> 2011-08-26 06:47:31 1.029177
> 2011-08-26 06:47:32 1.029177
> 2011-08-26 06:47:33 1.029177
> 2011-08-26 06:47:34 1.029177
> 2011-08-26 06:47:35 1.029178
> 2011-08-26 06:47:35 1.029178
> 2011-08-26 06:47:36 1.029178
> 2011-08-26 06:47:37 1.029178
> 2011-08-26 06:47:37 1.029178
> 2011-08-26 06:47:38 1.029178
> 2011-08-26 06:47:39 1.029179
> 2011-08-26 06:47:40 1.029179
> 2011-08-26 06:47:41 1.029179
> 2011-08-26 06:47:41 1.029179
> 2011-08-26 06:47:42 1.029179
> 2011-08-26 06:47:43 1.029179
> 2011-08-26 06:47:44 1.029179
> 2011-08-26 06:47:45 1.029179
> 2011-08-26 06:47:45 1.029179
> 2011-08-26 06:47:46 1.029179
> 2011-08-26 06:47:47 1.029180
> 2011-08-26 06:47:48 1.029180
> 2011-08-26 06:47:49 1.029180
> 2011-08-26 06:47:50 1.029180
> 2011-08-26 06:47:51 1.029180
> 2011-08-26 06:47:51 1.029180
> 2011-08-26 06:47:52 1.029180
> 2011-08-26 06:47:53 1.029180
> 2011-08-26 06:47:53 1.029180
> 2011-08-26 06:47:54 1.029180
> 2011-08-26 06:47:55 1.029180
> 2011-08-26 06:47:55 1.029180
> 2011-08-26 06:47:56 1.029180
> 2011-08-26 06:47:57 1.029180
> 2011-08-26 06:47:58 1.029180
> 2011-08-26 06:47:59 1.029180
> 2011-08-26 06:48:00 1.029180
> 2011-08-26 06:48:01 1.029180
> 2011-08-26 06:48:02 1.029180
>>
>
> --
> The hippies were right
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
> should go.
>



More information about the R-SIG-Finance mailing list