[R-SIG-Finance] Timeseries data, lattice, and model formulas?

icosa atropa icos.atropa at gmail.com
Fri Jul 6 07:41:45 CEST 2007


> Don't know what you are looking for with respect to factors but if you create
> a zoo object from a factor it remembers where it came from:

Thanks for the reply.  I need to read up on dynlm.
R.e. factors, I have something that looks like this - the first 3
columns have identifying info, and are the factors that I give to
lattice, whereas the last column is the actual timeseries.

> summary(M.full)
    unit_id  well_num              sampled_on                      dtw_m
 M1     :5   N:5        Min.   :2005-08-04 15:30:00    Min.   :-1.571
 M2     :0   S:0       1st Qu.:2005-08-04 15:45:00    1st Qu.:-1.570

Would the most logical way to use zoo be to create an object for each
element in the factor matrix, i.e. M1N, M1S, M2N, M2S, ... , and
create a list or environment of the objects?

Thanks!
christian

>
>    > zf <- zoo(factor(c(1,1,2)))
>    > class(zf)
>    [1] "zoo"
>    > str(zf)
>    atomic [1:3] 1 1 2
>     - attr(*, "levels")= chr [1:2] "1" "2"
>     - attr(*, "oclass")= chr "factor"
>     - attr(*, "index")= int [1:3] 1 2 3
>
> > lattice and
>
> zoo explicitly supports lattice with xyplot.zoo, e.g.
>
> library(zoo)
> library(lattice)
> example(xyplot.zoo)
>
> > model formulas seems lacking.  Am I missing something, or
>
> In conjuction with dyn or dynlm zoo supports model formula:
>
> library(dyn)
> set.seed(1)
> z <- zoo(rnorm(10))
> dyn$lm(z ~ lag(z, -1))
>


-- 
Far better an approximate answer to the right question, which is often
vague, than the exact answer to the wrong question, which can always
be made precise -- j.w. tukey



More information about the R-SIG-Finance mailing list