I was wondering what the best approach is for missing data in a time series.
I give an example using xts but I would like to know what seems to be the
"best" method. Say I have

 

library(xts)

xts.ts <- xts(1:4,as.Date(c("1970-01-01", "1970-1-3", "1980-10-10",
"2007-8-19")), frequency=52)

 

I would like to turn this into a time series (still could be xts, or
converted to ts) that has values for every week starting with the week that
includes the start date and ending with the week that includes the end date.
If there is data for the week then use it otherwise set it to NA or 0.
Remember some years have 52, 53, or rarely 54 full or partial weeks. What to
do with the partials at the beginning and ending of the year? This seems to
be a fairly common problem and doing it myself is very cumbersome. Does a
solution to this kind of problem exist? Once the approach to a weekly period
is found I am sure that adjustment to daily, monthly, or quarterly would be
relatively straightforward.

 

Thank you.

 

Kevin

 


        [[alternative HTML version deleted]]

______________________________________________
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