Hi everyone:

I did a search over the internet and still couldn't find answer to my problem.

I have a series of prices that I'm trying to clean up by removing any
prices greater than 3 times the standard deviations.  So, say that
prices are:

                        price1
2010-06-18 08:00:06.916   2730
2010-06-18 08:00:07.005   2730
2010-06-18 08:00:07.005   2729
2010-06-18 08:00:07.451   2730
2010-06-18 08:00:07.451   2730
2010-06-18 08:00:07.805   2730
2010-06-18 08:00:08.010   2730
2010-06-18 08:00:08.354   2730
2010-06-18 08:00:08.354   2729
2010-06-18 08:00:08.354   2729
2010-06-18 08:00:08.354   2730
2010-06-18 08:00:08.635   2730
2010-06-18 08:00:08.635   2730
2010-06-18 08:00:08.805   2730
2010-06-18 08:00:09.020   2731
2010-06-18 08:00:09.020   2731
2010-06-18 08:00:09.020   2731
2010-06-18 08:00:09.020   2731

I then find:
avg = mean(price, na.rm=T)
std = sd(price, na.rm=T)
t = abs(price-avg)
tt = which(t > 2.9*std)

I still was able to maintain class(t) = "xts" "zoo", but class(tt) =
"integer".  I need to keep tt to xts because anything that's more than
2.9*std will be filter out using the time stamp as the index.  If I
don't have the time stamp in tt, I'm not quite sure how I can filter
out unwanted prices.

I know that this code works on Linux side, but I have to translate it
to Windows side.  The data is fed in a little differently, but it
should works the same way now that I've translated the data into xts
object.  I'm not quite sure what I'm missing.  Any help is greatly
appreciated.

Thank you,
Manussawee

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to