Displaying 20 results from an estimated 400 matches similar to: "question about time series objects"
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 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?
2012 Jan 18
0
Time series questions
Hi, I am trying to teach myself some time series analysis.
I have some time series data on GDP, quarterly, from 1947 to 2011. colnames
are "Year" "Quarter" "GDP" and "GDP.deflator"
The first problem I have is that 4th quarter 2010 is missing--not even NA,
there is no record for Year=2010 and Quarter =4, so instead of 260 rows, I
only have 259. To solve
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
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
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
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
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
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
2007 Nov 24
1
Bug in package stats function ar() (PR#10459)
Full_Name: Steven McKinney
Version: 2.6.0
OS: OS X
Submission from: (NULL) (142.103.207.10)
Function ar() in package "stats" is showing
a quirky bug. Some calls to ar() run to
completion, others throw an error.
The bug is reproducible by several people on different
machines, however, the ar() function itself ends
up throwing the error sporadically. Several calls to
ar() may be
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
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
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)
1998 Aug 22
0
Handling of offsets in glm is really inconsistent.
[Copied to R-devel for information]
This applies to all versions of R I have: 0.62.2, 0.62.3, 0.63.
Great care seems 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
2012 Feb 06
3
Duplicate rows when I combine two data.frames with merge!
Hello all,
First I have done extensive searches on this forum and others and nothing
seems to work. So I decided to post thinking someone could point me to the
write post or give me some help.
I have drawn a 100 samples from a fictitious population (N=1000), and then
randomly selected 25% of the 100 samples. I would like to now merge the
data.frame from the 100 samples with the data.frame for
2006 May 31
0
Inconsistent behaviour when subsetting 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 the 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 =
2009 Nov 20
2
How to setup the tsp attribute of a dataset
Hello,
I am wondering how I should set up the tsp attribute (available through
attr(x, "tsp")) of a dataset x? Let's assume that x has 100 points, and
I want to set the frequency to 4.
I tried:
> attr(x,"tsp")<-c(1,100,4)
Error in attr(x, "tsp") <- c(1, 100, 4) :
invalid time series parameters specified
Is there any other way to set the frequency of
2007 Nov 23
4
help pleaseeeeeeeee
Dears Sirs
During my computational work I encountered unexpected behavior when calling
"ar" function, namely
# time series
x<-ts(c(-0.2052083,-0.3764986,-0.3762448,0.3740089,0.2737568,2.8235722,-
1.7783313,0.2728676,-0.3273164),start=c(1978,3),frequency=4,end=c(1980,3))
# ar function
res.ar<-ar(x,aic=TRUE,demean=F)
# call "ar" again and ............