Dear list,

I have some rasters, respresentig a time series (let's say 5 years and 24 rasters for each year). The rasters are in a raster stack or a SpatialGridDataframe, whatever is better.

Now I want to do some time series analysis which call for a ts class object.

# I have a brick called gimms with 144 layers:

gimms=brick(b)

# I summarize the cell values and create a time series:

s=cellStats(gimms, stat='mean')

gimms.ts = ts(s, start=c(2001,1), end=c(2006,24), frequency=24)

# I do some decomposition. The final result is the slope of a regression of the decomp. trend and the time:

gimms2.decomp = decompose(gimms.ts, type="multi")

gimms.trend = gimms2.decomp$trend

gimms.new = time(gimms.ts)

x = lm(gimms.trend ~ gimms.new)

summary(x)$coefficients[2]

Now what I want to do is to do the same with every single pixel and get a gridded result. What is the best appoach to start with? Is there a way to create a time series with my brick or SpatialGidDataframe? Beside this example there are also other things I want to do with my rasters which call for a "ts" class object, but I don't know where to start and I'd be thankful for any hints...

best wishes,

Martin