Displaying 20 results from an estimated 23 matches for "qtr3".
Did you mean:
ptr3
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.matrix(a1t...
2012 Apr 11
2
What is a better way to deal with lag/difference and loops in time series using R?
...es 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 Qtr2 Qtr3...
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("", start.pad)...
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 could do thi...
2012 Apr 12
4
Definition of "lag" is opposite in ts and xts objects!
...3 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)
...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), .Tsp = c(1962.25, 1...
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 deleted]]
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?
Thanks,
Jas...
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 I could figure out, is to cr...
2012 Jan 18
0
Time series questions
...ion: 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
snip
2009 20...
2007 Nov 24
1
Bug in package stats function ar() (PR#10459)
...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 -0.2052...
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
2011 Apr 08
1
Package mice: Error in if (meth[j] != "") { : argument is of length zero
...uot;norm",
maxit=0,
pred = quickpred(NewPrimal,
mincor = 0.25,
minpuc = 0.95,
include = c("D1", "D2", "D3",
"Qtr1", "Qtr2", "Qtr3",
"Feb", "Mar", "Apr", "May", "Jun", "Jul",
"Aug", "Sep", "Oct", "Nov", "Dec"),
exclude = c("Actu...
2008 Jan 10
1
question about subset and join ts object(s)
Hi,
I have two questions about ts.
(1) How do I subset a ts object and still preserve the time index? for
example:
> x=ts(1:10, frequency = 4, start = c(1959, 2)) # the ts object
> x
Qtr1 Qtr2 Qtr3 Qtr4
1959 1 2 3
1960 4 5 6 7
1961 8 9 10
I don't want the 1st 2 elements, so I could subset like this:
> x[3:length(x)]
[1] 3 4 5 6 7 8 9 10
But then the time index is lost. I could use window(), but then I have to
specify start and end manually. Is...
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 71 67...
2006 May 31
1
Inconsistent behaviour when manipulating a ts object with frequency = 12 or 4
...length of 'dimnames' [1] not equal to array extent
In addition: Warning message:
data length [30] is not a sub-multiple or multiple of the number of
columns [12] in matrix
> x <- ts(rnorm(6),frequency=4) # THE SAME BUT WITH frequency = 4
> x
Qtr1 Qtr2 Qtr3 Qtr4
1 -0.23823356 0.98744470 0.74139013 0.08934727
2 -0.95494386 -0.19515038
> x[24] <- NA
> x
Error in matrix(c(rep.int("", start.pad), format(x, ...), rep.int("", :
length of 'dimnames' [1] not equal to array extent
In addition: Warning mes...
1998 Aug 22
0
Handling of offsets in glm is really inconsistent.
...needed with glms with offsets, as many things seem
wrong.
Consider the following:
> data(freeny)
> freeny.glm <- glm(y ~ offset(lag.quarterly.revenue) + price.index +
income.level + market.potential, data=freeny, subset=1:30)
> predict(freeny.glm)
Qtr1 Qtr2 Qtr3 Qtr4
1962: NA 0.01040457 0.01073223 0.01233351
1963: 0.01211730 0.02744293 0.03259214 0.03225403
1964: 0.03235081 0.03272723 0.03361984 0.03114351
1965: 0.03128098 0.03371820 0.02869783 0.02670215
1966: 0.02346093 0.02172193 0.02269731 0.01927851
1967: 0.02516107 0.02496217 0.02679227...
2006 May 31
0
Inconsistent behaviour when subsetting a ts object with frequency = 12 or 4
...length of 'dimnames' [1] not equal to array extent
In addition: Warning message:
data length [30] is not a sub-multiple or multiple of the number of
columns [12] in matrix
> x <- ts(rnorm(6),frequency=4) # THE SAME BUT WITH frequency = 4
> x
Qtr1 Qtr2 Qtr3 Qtr4
1 -0.23823356 0.98744470 0.74139013 0.08934727
2 -0.95494386 -0.19515038
> x[24] <- NA
> x
Error in matrix(c(rep.int("", start.pad), format(x, ...), rep.int("", :
length of 'dimnames' [1] not equal to array extent
In addition: Warning mes...
2011 Apr 01
0
package MICE, squeeze function, calling several variables at once
..., "blnMothersDay", "blnMemorialDay", "blnFathersDay", "blnIndependenceDay", "blnLaborDay", "blnThanksgiving", "blnChristmas", "Qtr1", "Qtr2", "Qtr3", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"), exclude = c("ActualW...