search for: qtr1

Displaying 20 results from an estimated 30 matches for "qtr1".

Did you mean: ptr1
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 74 75 60 1954 71 61 71 57 1955 71 68 79 73 1956 76...
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 workspace, I see structure(11:22, .Tsp = c(1978, 1980.75, 4), class = "ts") If I coerce the variable to become a matrix, > a1tsm<-as....
2012 Apr 11
2
What is a better way to deal with lag/difference and loops in time series using R?
...riting 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 -0.009953715 -0.015059485 1984 -1.190061246 -0.553031799 0.686874720 0.953911035 If I would like to create a time series vector containing the data in 4 quarters ahead > PI4<-lag(PI1,4)> PI4 Qtr1...
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 86 89 92 95 1993 98 > aggregate(lag(try,-1),4,mean,na.rm=T) Error in rep.int("",...
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 for the 1st quarter would be mean(c(4,8,12,16,20)), which is 12. But I am wondering if there is a R function that co...
2012 Apr 12
4
Definition of "lag" is opposite in ts and xts objects!
...984 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 2.791594762 1984 Q3 -0.009953715 1984 Q4 -0.015059485> lag(as.ts(a, start=c(1983,1)),4) Qtr1 Qtr2 Qtr3 Qtr4 1982 2.747365190 2.791594762 -0.009953715 -0.015059485 1983 -1.190061246 -0.553031799 0.686874720 0.953911035 [[alternative HTML version deleted]]
1999 Feb 18
1
model.frame mangles time series (PR#121)
...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 multiple of the elements to replace in matrix(...) Error: length of dimnames[1] not equal to array extent > model.frame(y~1,data=freeny[1:10,])$y Qtr1 Qtr2 Qtr3 Qtr4 1962: NA 8.79236 8.79137 8.81486 1963: 8.81301 8.90751 8.93673 8.96161 1964: 8.96044 9.00868 9.03049 NA > dput(model.frame(y~1,data=freeny,subset=1:10)$y) structure(c(8.79236, 8.79137, 8.81486, 8.81301, 8.90751, 8.93673, 8.96161, 8.96044, 9.00868, 9.03049), .Ts...
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 . . . . . . . . . . 1979 14.04 12.96 14.85 9.99 1980 16.20 14.67 16.02 11.61* How do I access the value for 1961 quarter 3 (say)? Dipankar [[alternative HTML version dele...
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 from a &...
2024 Jun 10
2
head.ts, tail.ts loses time
...ding such methods to "base R"'s utils package. Martin > Best Wishes, Spencer Graves > On 6/9/24 8:40 PM, Gabor Grothendieck wrote: >> 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: >&...
2024 Jun 10
1
head.ts, tail.ts loses time
..., so "head" cannot return a ts object, because "[" doesn't. Best Wishes, Spencer Graves On 6/9/24 8:40 PM, Gabor Grothendieck wrote: > 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...
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 like tsobject[1999,Qtr4] (or something close to that) to return 4, not the error. Any suggestions? Th...
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? 0.0716002123? 0.2551020416? 0.0977574743 -0.0739337411 #??? ... #? The time series is 216 long #? The easiest way...
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? Spencer Graves head.ts <- function(x, n=6L, ...){ tmx <- as.numeric(time(x)) # utils:::checkHT(n, d <- dim...
2024 Jun 11
1
head.ts, tail.ts loses time
...s package. > > > Martin > > > Best Wishes, Spencer Graves > > > > On 6/9/24 8:40 PM, Gabor Grothendieck wrote: > >> 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: > >>> >...
2012 Jan 18
0
Time series questions
...irst question: what is the difference between gdp.ts <- ts(gdpdata$GDP, start=1947, end=2011, fr=4) and gdp2.ts <- ts(gdpdata$GDP, start=c(1947,1), end=c(2011,4), fr=4) I get different outputs for time(gdp.ts) and time(gdp2.ts), and neither make sense. time(gdp.ts) gives me this: Qtr1 Qtr2 Qtr3 Qtr4 1947 1947 1947 1948 1948 1948 1948 1948 1948 1949 1949 1949 1949 1950 1950 snip 2009 2009 2009 2010 2010 2010 2010 2010 2010 2011 2011 2011 time(gdp2.ts) gives me this: Qtr1 Qtr2 Qtr3 Qtr4 1947 1947 1947 1948 1948 1948 1948 1948 1948 1949 1949 1949 1949 1950 1950 sn...
2024 Jun 10
1
head.ts, tail.ts loses time
...g > > > Martin > > > Best Wishes, Spencer Graves > > > > On 6/9/24 8:40 PM, Gabor Grothendieck wrote: > >> 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: > >>>...
2007 Nov 24
1
Bug in package stats function ar() (PR#10459)
...g messages: 1: In log(var.pred) : NaNs produced 2: In if (order > 0) coefs[order, 1:order] else numeric(0) : the condition has length > 1 and only the first element will be used > > # call "ar" again and ............ > res.ar<-ar(x,aic=TRUE,demean=F) > x Qtr1 Qtr2 Qtr3 Qtr4 1978 -0.2052083 -0.3764986 1979 -0.3762448 0.3740089 0.2737568 2.8235722 1980 -1.7783313 0.2728676 -0.3273164 > res.ar<-ar(x,aic=TRUE,demean=F) > res.ar$resid Qtr1 Qtr2 Qtr3 Qtr4 1978...
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