| To: | s-news@lists.biostat.wustl.edu |
|---|---|
| Subject: | Question in Time-Series -SUMMARY |
| From: | Pat Farr <patricia.farra@rogers.com> |
| Date: | Wed, 25 May 2005 08:26:35 -0400 (EDT) |
|
I received prompt, kind, and valuable suggestions from Laura Holt and Henrik Aalborg Nielsen. Many thanks! The suggestions follow. If you are interested in time series, please read to the end. In multivariate time series as considered in this posting, the individuals (subjects) are the variables and measurement occasion gives a serie. I was right saying "I am afraid I am missing theory".
Laura Holt wrote:
Do you mean a multivariate time series, please?
>x1 <- matrix(rnorm(40),nrow=4,ncol=10) >x1.ts <- rts(x1,frequency=2,start=1995) >x1.ts Series 1 Series 2 Series 3 Series 4 Series 5 Series 6 Series 7 Series 8 Series 9 Series 10 1995.0 0.4692720 0.7460260 -0.8682816 -0.3630142 0.5585065 -0.3924150 -0.1154636 -1.6124470 1.8504896 0.06445123 1995.5 -0.4837774 -0.5160213 -0.4999353 -0.4086840 -0.4596804 -1.8399909 -2.4181038 -2.4651423 -1.8367840 -0.67806762 1996.0 0.6136543 1.4780755 -1.2902717 -1.4098757 -1.1124667 2.6178822 2.4640857 0.1587029 2.2451479 0.07457770 1996.5 -1.8427487 -0.6714690 0.2860823 -1.0762595 -0.3879411 -0.7800703 -1.0769670 -0.9179550 -0.3266432 -0.57922833 start deltat frequency 1995 0.5 2 > You need 10 series, with a frequency of 2 (for the 6 months) Hope this helps! Sincerely, Laura Your suggestion works! However, it puts me in another difficulty as I have more than two variables. > serie1<-c(11, 9, 11, 22, 21, 19, 19, 15, 13, 7) > serie2<-c(15, 17, 14, 17, 15, 24, 12, 11, 12, 4) > serie3<-c(13, 12, 15, 6, 15, 17, 13, 7, 19, 11) > serie4<-c(18, 15, 15, 9, 13, 13, 12, 10, 17, 12) > x<-as.matrix(rbind(serie1,serie2,serie3,serie4)) > x.ts <- rts(x,frequency=2,start=2001) > x.ts > Series 1 Series 2 Series 3 Series 4 Series 5 Series 6 Series 7 Series 8 Series 9 Series 10 >serie1 11 9 11 22 21 19 19 15 13 7 >serie2 15 17 14 17 15 24 12 11 12 4 >serie3 13 12 15 6 15 17 13 7 19 11 >serie4 18 15 15 9 13 13 12 10 17 12 start deltat frequency 2001 0.5 2 When I consider all the 40 observations on variables together, I have: > serie<-c(serie1,serie2,serie3,serie4) > serie [1] 11 9 11 22 21 19 19 15 13 7 15 17 14 17 15 24 12 11 12 4 13 12 15& nbsp; 6 15 17 13 7 19 11 18 15 15 9 13 13 12 10 >[39] 17 12 > rts(serie,frequency=2,start=2001) 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 >2001: 11 9 11 22 21 19 19 15 13 7 15 17 14 17 15 24 12 11 12 4 13 12 15 6 15 17 13 7 19 11 18 15 15 9 13 13 12 10 >2020: 17 12 start deltat frequency 2001 0.5 2 showing my observations "ended" in 2020! I would be very appreciative of your help to extend your suggestion to three variables assuming equal spacing of 6 months (to make it ea sy until I understand what is going on; I would prefer its() to rts()). Sincerely, Pat Laura, very knidly, replied: Ok. You have 10 variables: seri1 through serie10.
Each series has 4 observations. What I did was put together some fake dates in the next step: >obs.times <- dates(c("01/01/1995","07/01/1998","12/01/1999","01/01/2003")) >obs.times [1] 01/01/1995 07/01/1998 12/01/1999 01/01/2003 Here, I just generated a matrix. What you would want to do is cbind(seri1,seri2,seri3) >x <- matrix(rnorm(40),nrow=4,ncol=10) Now I create an its. The data is in x, while the observation times are in obs.times. >x.its <- its(x, times=obs.times) >x.its Series 1 Series 2 Series 3 Series 4 Series 5 Series 6 Series 7 Series 8 Series 9 Series 10 01/01/1995 -0.96275047 0.3086150 -0.3232615 0.7133833 0.8644014 -1.6 651707 -0.76674859 1.3370470 1.2941335 -0.5012535 07/01/1998 1.00891721 -2.8632682 -0.9608544 0.3475233 -1.2520791 1.6180516 0.72959253 1.0774104 0.7418033 0.1483676 12/01/1999 -1.32420419 -0.7070052 -0.9639293 0.1648563 0.1603369 -0.2901317 0.12260904 0.1657497 -0.4931657 -0.9986250 01/01/2003 -0.03907015 0.1445699 1.9400356 1.0557461 0.7901353 -0.1000546 0.07382149 -1.6310907 -0.2132029 0.2581173 start end 01/01/1995 ... 01/01/2003 > You actually don't have 40 observations in the sense that there are 40 observations in 1 series. You have 10 variables...maybe they represent people. X1 is person one, X2 is person two, and so on. Every six months you return to each person and ask him/her a question. Does this help?  ; Time series (particularly multivariate time series) can be a bit tricky at first. Henrik Aalborg Nielsen wrote: Dear Pat,
If I understand you correct you follow 10 individuals for 18 months and collect data on each individual every six months; resulting in 4 measurements for each individual. I believe this should be handled as longitudinal data analysis. Venables and Ripley "Modern applied statistics with S-PLUS" has a section on this (10.3 in the 2nd ed). Regards, Henrik Enjoy,
Pat
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | [Job ad] Insightful looking for statistical consultants to meet increasing consulting demand, Lou Bajuk |
|---|---|
| Next by Date: | Re: Question in Time-Series -SUMMARY, Alain Yamakana |
| Previous by Thread: | [Job ad] Insightful looking for statistical consultants to meet increasing consulting demand, Lou Bajuk |
| Next by Thread: | Re: Question in Time-Series -SUMMARY, Alain Yamakana |
| Indexes: | [Date] [Thread] [Top] [All Lists] |