I have also had this problem recently and found a solution. I don't have time
to re-edit it so in case it's helpful, here it is in its more or less original
form.
Generally wouldn't it be good to have some simple ways of handling timeSeries
and timeDate objects?
#the following 4 time series have different lengths and different frequencies
(some quarterly some annual)
Banks.Med.pct.ts<-timeSeries(Banks.Med.pct,BanksTime,units="Percent")
Banks.Mean.pct.ts<-timeSeries(Panama.10JuneB$Total.Exposure,BanksTime,units="Percent")
CU.Med.ts<-timeSeries(CU.Med.pct,BSTime,units="Percent")
BS.ts<-timeSeries(BS.Med.pct,BSTime,units="Percent")
#the following does exactly what it ought to do, but I cannot see how to
extract the multiple time series from the 4:
plot(Banks.Med.pct.ts,Banks.Mean.pct.ts,CU.Med.ts,BS.ts)
#this below enables use of ts.union but loses the timeSeries features:
Banks.cts<-cts(cbind(Banks.Med.pct,Panama.10JuneB$Total.Exposure),dates("01/28/1990"),"months",names=c("Median","Average"))
CUBS.cts<-cts(cbind(CU.Med.pct,BS.Med.pct),dates("03/28/1993"),"quarters",names=c("Credit
Unions","Building Societies"))
#the fllowing objects have the correct behaviour
ADIs.all<-ts.union(Banks.cts,CUBS.cts)
Hope this helps.
Alun
____________________
Dr Alun Pope
Statistics Consultant
Australian Prudential Regulation Authority
400 George Street, Sydney NSW 2000, Australia
GPO Box 9836, Sydney NSW 2001, Australia
Tel: (02) 9210 3232
Fax: (02) 9210 3021
E-mail: alun.pope@apra.gov.au
-----Original Message-----
From: Horace Tso [mailto:Horace_Tso@pgn.com]
Sent: Friday, 20 June 2003 11:24 AM
To: s-news@lists.biostat.wustl.edu
Subject: [S] Merging Time Series
Hi folks,
Using 6.1 under Win2K, I want to do a Union of two Time Series.
Sounds simple? I've tried every trick out there and nothing works. SPlus
support suggests using merge(), but that doesn't work. Each series has
identical column names, Y1, Y2, Y3. There are some overlapping dates in both.
Here they are,
> t1
Position Y1 Y2 Y3
02/12/1997 7.00 6.50 7.50
02/26/1997 6.50 6.25 6.75
02/27/1997 6.50 6.25 6.75
02/28/1997 6.50 6.25 6.75
03/01/1997 6.50 6.25 6.75
03/03/1997 6.50 6.25 6.75
03/04/1997 9.21 7.25 10.00
03/05/1997 10.00 9.75 10.25
03/06/1997 8.75 8.50 9.00
>t2
Position Y1 Y2 Y3
02/12/1997 6.00 8.50 7.50
02/26/1997 6.15 6.00 6.75
02/27/1997 4.50 4.25 4.75
02/28/1997 3.50 3.25 3.25
03/01/1997 6.50 6.25 6.75
03/04/1997 6.50 6.25 6.75
03/05/1997 1.21 2.25 1.00
03/08/1997 1.00 0.75 0.25
03/09/1997 2.25 2.50 2.00
I want to create the following,
Position Y1 Y2 Y3 Y11 Y21 Y31
02/12/1997 6.00 8.50 7.50 7.00 6.50 7.50
02/26/1997 6.15 6.00 6.75 6.50 6.25 6.75
02/27/1997 4.50 4.25 4.75 6.50 6.25 6.75
02/28/1997 3.50 3.25 3.25 6.50 6.25 6.75
03/01/1997 6.50 6.25 6.75 6.50 6.25 6.75
03/03/1997 NA NA NA 6.50 6.25 6.75
03/04/1997 6.50 6.25 6.75 9.21 7.25 10.00
03/05/1997 1.21 2.25 1.00 10.00 9.75 10.25
03/06/1997 NA NA NA 8.75 8.50 9.00
03/08/1997 1.00 0.75 0.25 NA NA NA
03/09/1997 2.25 2.50 2.00 NA NA NA
Thanks a lot.
Horace W. Tso
Senior Quantitative Analyst
Portland General Electric
Portland, Oregon
503-464-8430 (D)
IMPORTANT NOTICE:
This e-mail is intended solely for the person or organisation to whom it is
addressed, and may contain secret, confidential or legally privileged
information.
If you have received this e-mail in error or are aware that you are not
authorised to have it, you MUST NOT use or copy it, or disclose its contents
to any person. If you do any of these things, you may be sued or prosecuted.
If you have received this e-mail in error, please contact the sender
immediately.
|