[R-SIG-Finance] disaggregate from monthly to daily time series

Robert Sams robert at sanctumfi.com
Mon Jul 27 20:27:01 CEST 2009


Hi John,

Does this work for you?

> library(zoo)
> (cpi <- zoo(c(212.174, 213.007, 212.714, 212.671, 212.876, 214.459),
order.by=as.Date(ISOdate(2009, 2:7, 1))))
2009-02-01 2009-03-01 2009-04-01 2009-05-01 2009-06-01 2009-07-01 
   212.174    213.007    212.714    212.671    212.876    214.459 
> na.spline(merge(cpi, foo=zoo(NA, order.by=seq(start(cpi), end(cpi),
"day")))[, 1])
2009-02-01 2009-02-02 2009-02-03 2009-02-04 2009-02-05 2009-02-06
2009-02-07 2009-02-08 2009-02-09 2009-02-10 
  212.1740   212.2373   212.2976   212.3550   212.4096   212.4614
212.5105   212.5568   212.6006   212.6418 
2009-02-11 2009-02-12 2009-02-13 2009-02-14 2009-02-15 2009-02-16
2009-02-17 2009-02-18 2009-02-19 2009-02-20 
  212.6805   212.7167   212.7505   212.7819   212.8110   212.8379
212.8626   212.8851   212.9056   212.9240 
2009-02-21 2009-02-22 2009-02-23 2009-02-24 2009-02-25 2009-02-26
2009-02-27 2009-02-28 2009-03-01 2009-03-02 
  212.9404   212.9549   212.9676   212.9784   212.9874   212.9948
213.0004   213.0045   213.0070   213.0080 
2009-03-03 2009-03-04 2009-03-05 2009-03-06 2009-03-07 2009-03-08
2009-03-09 2009-03-10 2009-03-11 2009-03-12 
  213.0076   213.0059   213.0028   212.9986   212.9932   212.9868
212.9795   212.9712   212.9621   212.9523 
2009-03-13 2009-03-14 2009-03-15 2009-03-16 2009-03-17 2009-03-18
2009-03-19 2009-03-20 2009-03-21 2009-03-22 
  212.9417   212.9306   212.9190   212.9069   212.8944   212.8817
212.8687   212.8556   212.8424   212.8292 
2009-03-23 2009-03-24 2009-03-25 2009-03-26 2009-03-27 2009-03-28
2009-03-29 2009-03-30 2009-03-31 2009-04-01 
  212.8161   212.8031   212.7904   212.7780   212.7659   212.7543
212.7433   212.7328   212.7230   212.7140 
2009-04-02 2009-04-03 2009-04-04 2009-04-05 2009-04-06 2009-04-07
2009-04-08 2009-04-09 2009-04-10 2009-04-11 
  212.7058   212.6984   212.6917   212.6858   212.6805   212.6759
212.6719   212.6686   212.6657   212.6634 
2009-04-12 2009-04-13 2009-04-14 2009-04-15 2009-04-16 2009-04-17
2009-04-18 2009-04-19 2009-04-20 2009-04-21 
  212.6615   212.6601   212.6591   212.6585   212.6583   212.6583
212.6586   212.6591   212.6598   212.6607 
2009-04-22 2009-04-23 2009-04-24 2009-04-25 2009-04-26 2009-04-27
2009-04-28 2009-04-29 2009-04-30 2009-05-01 
  212.6617   212.6629   212.6640   212.6652   212.6664   212.6676
212.6686   212.6696   212.6704   212.6710 
2009-05-02 2009-05-03 2009-05-04 2009-05-05 2009-05-06 2009-05-07
2009-05-08 2009-05-09 2009-05-10 2009-05-11 
  212.6714   212.6717   212.6718   212.6719   212.6720   212.6722
212.6725   212.6731   212.6739   212.6750 
2009-05-12 2009-05-13 2009-05-14 2009-05-15 2009-05-16 2009-05-17
2009-05-18 2009-05-19 2009-05-20 2009-05-21 
  212.6764   212.6783   212.6807   212.6837   212.6872   212.6915
212.6964   212.7022   212.7088   212.7163 
2009-05-22 2009-05-23 2009-05-24 2009-05-25 2009-05-26 2009-05-27
2009-05-28 2009-05-29 2009-05-30 2009-05-31 
  212.7248   212.7343   212.7449   212.7567   212.7696   212.7838
212.7994   212.8163   212.8347   212.8546 
2009-06-01 2009-06-02 2009-06-03 2009-06-04 2009-06-05 2009-06-06
2009-06-07 2009-06-08 2009-06-09 2009-06-10 
  212.8760   212.8991   212.9238   212.9502   212.9784   213.0084
213.0402   213.0738   213.1094   213.1469 
2009-06-11 2009-06-12 2009-06-13 2009-06-14 2009-06-15 2009-06-16
2009-06-17 2009-06-18 2009-06-19 2009-06-20 
  213.1864   213.2280   213.2716   213.3174   213.3653   213.4154
213.4678   213.5224   213.5793   213.6387 
2009-06-21 2009-06-22 2009-06-23 2009-06-24 2009-06-25 2009-06-26
2009-06-27 2009-06-28 2009-06-29 2009-06-30 
  213.7004   213.7646   213.8312   213.9004   213.9722   214.0465
214.1236   214.2033   214.2857   214.3710 
2009-07-01 
  214.4590 
> 
 
Robert

> -----Original Message-----
> From: r-sig-finance-bounces at stat.math.ethz.ch 
> [mailto:r-sig-finance-bounces at stat.math.ethz.ch] On Behalf Of 
> John P. Burkett
> Sent: 27 July 2009 19:05
> To: r-sig-finance at stat.math.ethz.ch
> Subject: [R-SIG-Finance] disaggregate from monthly to daily 
> time series
> 
> I would like to disaggregate a monthly average (Consumer 
> Price Index) to create a daily time series.  The new daily 
> series should be smooth (i.e.--exhibit no unusual jump from 
> the last day of a month to the first day of the next month) 
> and be consistent with the original monthly data (i.e.--the 
> average value of the new series for the days of a month 
> should equal the given value for that month).
> 
> If all months had 30 days and I were using S+Finmetrics, I 
> would try to create the daily series with a command such as 
> disaggregate(CPI, 30, method="spline", how="mean") where CPI 
> is the monthly data on the Consumer Price Index.
> The fact that months are of different lengths complicates matters.
> 
> Suggestions for how to accomplish the disaggregation in R 
> would be greatly appreciated.
> 
> -John
> 
> --
> John P. Burkett
> Department of Economics
> University of Rhode Island
> Kingston, RI 02881-0808
> USA
> 
> phone (401) 874-9195
> 
> _______________________________________________
> 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