similar to: question about subset and join ts object(s)

Displaying 20 results from an estimated 3000 matches similar to: "question about subset and join ts object(s)"

2012 Apr 11
2
What is a better way to deal with lag/difference and loops in time series using R?
Hello, I am writing codes for time series computation but encountering some problems Given the quarterly data from 1983Q1 to 1984Q2 PI1<-ts(c(2.747365190,2.791594762, -0.009953715, -0.015059485, -1.190061246, -0.553031799, 0.686874720, 0.953911035), start=c(1983,1), frequency=4) > PI1 Qtr1 Qtr2 Qtr3 Qtr4 1983 2.747365190 2.791594762
2005 May 10
1
Aggregate lag
hello, Does anybody know how to aggregate a lag series ? when I try to use aggregate I get the following message > try<-ts(1:100,start=c(1985,1),freq=12) > aggregate(try,4,mean,na.rm=T) Qtr1 Qtr2 Qtr3 Qtr4 1985 2 5 8 11 1986 14 17 20 23 1987 26 29 32 35 1988 38 41 44 47 1989 50 53 56 59 1990 62 65 68 71 1991 74 77 80 83 1992
2008 Jan 06
1
aggregate.ts help
Hi, I have a ts object with a frequency of 4, i.e., quarterly data, and I would like to calculate the mean for each quarter. So for example: > ts.data=ts(1:20,start=c(1984,2),frequency=4) > ts.data Qtr1 Qtr2 Qtr3 Qtr4 1984 1 2 3 1985 4 5 6 7 1986 8 9 10 11 1987 12 13 14 15 1988 16 17 18 19 1989 20 If I do this manually, the mean
2010 Sep 22
2
Unique subsetting question
Hi all, I'm looking at a large data set, and I'm interested in removing rows where only one variable is duplicated. Here's an example: > presidents Qtr1 Qtr2 Qtr3 Qtr4 1945 NA 87 82 75 1946 63 50 43 32 1947 35 60 54 55 1948 36 39 NA NA 1949 69 57 57 51 1950 45 37 46 39 1951 36 24 32 23 1952 25 32 NA 32 1953 59
2012 Apr 12
4
Definition of "lag" is opposite in ts and xts objects!
Example: Will ts objects be obsolete or modified? > a [,1] 1983 Q1 2.747365190 1983 Q2 2.791594762 1983 Q3 -0.009953715 1983 Q4 -0.015059485 1984 Q1 -1.190061246 1984 Q2 -0.553031799 1984 Q3 0.686874720 1984 Q4 0.953911035> lag(a,4) [,1] 1983 Q1 NA 1983 Q2 NA 1983 Q3 NA 1983 Q4 NA 1984 Q1 2.747365190 1984 Q2
2010 Jan 30
2
question about time series objects
Hi All, I have a very simple question about a time series object: how to access values for a particular year and quarter (say)? Suppose, following http://www.stat.pitt.edu/stoffer/tsa2/R_time_series_quick_fix.htm I have read in data as a time series; here is how it looks. * Qtr1 Qtr2 Qtr3 Qtr4 1960 0.71 0.63 0.85 0.44 1961 0.61 0.69 0.92 0.55 . . . . .
2012 Feb 17
4
How can I tabulate time series data (in RStudio or any other R editor)?
Hello, I have a question on how to tabulate the time series data. I use RStudio, but if can be done in any other R editor, it should work in RStudio as well. > a1<-11:22 > a1ts<-ts(a1, frequency=4, start=c(1978,1)) > a1ts Qtr1 Qtr2 Qtr3 Qtr4 1978 11 12 13 14 1979 15 16 17 18 1980 19 20 21 22 If I click the variable "a1ts" on the
2024 Jun 10
1
head.ts, tail.ts loses time
zoo overcomes many of the limitations of ts: library(zoo) as.ts(head(as.zoo(presidents))) ## Qtr1 Qtr2 Qtr3 Qtr4 ## 1945 NA 87 82 75 ## 1946 63 50 xts also works here. On Sun, Jun 9, 2024 at 12:04?PM Spencer Graves <spencer.graves at prodsyse.com> wrote: > > Hello, All: > > > The 'head' and 'tail' functions strip the time
2024 Jun 10
2
head.ts, tail.ts loses time
>>>>> Spencer Graves >>>>> on Mon, 10 Jun 2024 07:50:13 -0500 writes: > Hi, Gabor et al.: Thanks for this. I should change my > current application to use either zoo or xts, as Gabor > suggests. > However, I was surprised to learn that "[.ts" does NOT > return an object of class "ts". I see that
2024 Jun 10
1
head.ts, tail.ts loses time
Hi, Gabor et al.: Thanks for this. I should change my current application to use either zoo or xts, as Gabor suggests. However, I was surprised to learn that "[.ts" does NOT return an object of class "ts". I see that "head.default" and "head.matrix" both call "[", so "head" cannot return a ts object, because "["
2003 Nov 25
1
Time series indexing/subsetting
R-listers: I may be asking too much from R, but is there a way to use time indexing on a time series object. For instance: > tsobject <- ts(1:12, start =1999, freq = 4) > tsobject Qtr1 Qtr2 Qtr3 Qtr4 1999 1 2 3 4 2000 5 6 7 8 2001 9 10 11 12 > tsobject[1999,Qtr4] Error in NextMethod("[") : Object "Qtr4" not found I would
2024 Jun 11
1
head.ts, tail.ts loses time
It isn't really clear that it can't work. This does work by inserting NA's. library(zoo) as.ts(as.zoo(lynx)[ c(1:3, 7) ] ) ## Time Series: ## Start = 1821 ## End = 1827 ## Frequency = 1 ## [1] 269 321 585 NA NA NA 3928 On Mon, Jun 10, 2024 at 10:32?AM Martin Maechler <maechler at stat.math.ethz.ch> wrote: > > >>>>> Spencer Graves
2024 Jun 10
1
head.ts, tail.ts loses time
Hi, Martin et al.: On 6/10/24 9:32 AM, Martin Maechler wrote: >>>>>> Spencer Graves >>>>>> on Mon, 10 Jun 2024 07:50:13 -0500 writes: > > > Hi, Gabor et al.: Thanks for this. I should change my > > current application to use either zoo or xts, as Gabor > > suggests. > > > > However, I was
1999 Feb 18
1
model.frame mangles time series (PR#121)
This one showed up while looking at one of Ripley's other reports: > data(freeny) > model.frame(y~1,data=freeny,subset=1:10) y 1962.25 8.79236 1962.5 8.79137 1962.75 8.81486 1963 8.81301 1963.25 8.90751 1963.5 8.93673 1963.75 8.96161 1964 8.96044 1964.25 9.00868 1964.5 9.03049 > model.frame(y~1,data=freeny,subset=1:10)$y Warning: Replacement length not a
2007 Jul 25
3
aggregate.ts
Consider the following scrap of code: > x<- ts(1:50,start=c(1,11),freq=12) > y <- aggregate(x,nfreq=4) > c(y) [1] 6 15 24 33 42 51 60 69 78 87 96 105 114 123 132 141 > y Error in rep.int("", start.pad) : invalid number of copies in rep.int() > tsp(y) [1] 1.833333 5.583333 4.000000 So we can aggregate into quarters, but we cannot print it using
2007 Jul 25
3
aggregate.ts
Consider the following scrap of code: > x<- ts(1:50,start=c(1,11),freq=12) > y <- aggregate(x,nfreq=4) > c(y) [1] 6 15 24 33 42 51 60 69 78 87 96 105 114 123 132 141 > y Error in rep.int("", start.pad) : invalid number of copies in rep.int() > tsp(y) [1] 1.833333 5.583333 4.000000 So we can aggregate into quarters, but we cannot print it using
2024 Jun 09
2
head.ts, tail.ts loses time
Hello, All: The 'head' and 'tail' functions strip the time from a 'ts' object. Example: > head(presidents) [1] NA 87 82 75 63 50 > window(presidents, 1945, 1946.25) Qtr1 Qtr2 Qtr3 Qtr4 1945 NA 87 82 75 1946 63 50 Below please find code for 'head.ts' and 'tail.ts' that matches 'window'. Comments?
2006 May 31
1
Inconsistent behaviour when manipulating a ts object with frequency = 12 or 4
Dear All, I found the following under R 2.3.0 on WINXP (tested on 2 PCs, I do not have access to Linux from this PC, sorry ... ) > set.seed(10) > x <- ts(rnorm(6),frequency=7) > x Time Series: Start = c(1, 1) End = c(1, 6) Frequency = 7 [1] 0.01874617 -0.18425254 -1.37133055 -0.59916772 0.29454513 0.38979430 > x[24] <- NA > x Time Series: Start = c(1, 1) End = c(1, 6)
2010 Mar 18
1
Regression of a time series on its Quarters
# Dear List, # I want to characterize a time series according to its Quarter components. # My data ("a.ts": http://docs.google.com/View?id=dfvvwzr2_478cr9k4cdb)? look like: #???????????????? Qtr1????????? Qtr2????????? Qtr3????????? Qtr4 #?? 1948 -0.0714961837? 0.0101747827? 0.0654816569 -0.0227830729 #?? 1949 -0.1175517556? 0.1151378692? 0.1015777858 -0.1971535900 #?? 1950?
2024 Jun 13
0
head.ts, tail.ts loses time
> It isn't really clear that it can't work. This does work by inserting NA's... > > library(zoo) > as.ts(as.zoo(lynx)[ c(1:3, 7) ] ) If by 'this' you mean indexing, it would be very confusing and error prone for expressions like lynx[c(1:3, 7)] (lynx is from class 'ts') to return a ts object with NA's inserted and, even more so, since this has been