disaggregating weekly to daily series
The zoo package can do that in one line but first read the weekly data into a zoo object, w, and the dates into a one-column data frame d. library(zoo) Lines <- "1999-02-19 128.72 1999-02-26 129.15 1999-03-05 131.76 " w <- read.zoo(textConnection(Lines)) Lines <- "1999-02-15 1999-02-16 1999-02-17 1999-02-18 1999-02-19 1999-02-22 1999-02-23 1999-02-24 " d <- read.table(textConnection(Lines), colClasses = "Date") # Now create a 0-width zoo object from the dates, d, and merge it with the # weekly zoo object. Then use na.locf to fill in NAs with Last Observation # Carried Forward. na.locf(merge(w, zoo(, d[[1]])))
On Nov 13, 2007 10:22 PM, Ian Seow <ianseow at gmail.com> wrote:
Hi guys, was wondering if there was any elegant function to transform a weekly financial timeseries into a daily series. The tricky part about the daily series is that it is irregular - it doesn't include trading holidays and weekends. Both date vectors weekly and daily are given. For instance: Weekly series:- 1999-02-19 128.72 1999-02-26 129.15 1999-03-05 131.76 ... etc ... To this Daily series:- 1999-02-15 128.72 1999-02-16 128.72 1999-02-17 128.72 1999-02-18 128.72 1999-02-19 128.72 1999-02-22 129.15 1999-02-23 129.15 1999-02-24 129.15 ... etc ... Thanks. Rgds Ian Seow
_______________________________________________ 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.