Actually, i had checked out the methods of time series (TS), but i had
thought it cannot solve it. TS may only considers the autocorrelation of Y
in different time, but not Xs. Besides Y, i also have several independent
variables.
  Following your suggestion, i browsed the dynlm package and found
it is helpful. Lag function (e.g.lag(x, lag = -k)) may solve the problem.
That is, TS plus Lag function may finally solve my task. But one question is
how to determine the best k for Y and Xs.
  Thanks.
2009/3/6 Greg Snow <greg.s...@imail.org>

> I think that the dynlm package was designed for just such a problem.  I
> also would not be surprised if there are tools in the zoo package to do
> this.  You should probably check out the time series task view on CRAN as
> well.
>
> Hope this helps,
>
> --
> Gregory (Greg) L. Snow Ph.D.
> Statistical Data Center
> Intermountain Healthcare
> greg.s...@imail.org
> 801.408.8111
>
>
> > -----Original Message-----
> > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> > project.org] On Behalf Of zhijie zhang
> > Sent: Thursday, March 05, 2009 8:56 AM
> > To: r-h...@stat.math.ethz.ch
> > Subject: [R] Does R have function or method to finish my task?
> >
> > Dear all,
> >   Does R have function or method to finish the following task.
> > Say i have a dataset. The response variable is Y, and the indepedent
> > variables are X1, X2, X3, and YEAR. See an example.
> > Y              X1            X2            X3          X4
> > YEAR
> > 13.4         2.8           3.5              2.5      1.8          1990
> > 10.5        1.8            2.4              2          3           1991
> >             ....          .....
> >  In ecology, Y may be not only related with X1, X2, X3 in the same year
> > as
> > Y, but also may be related with X1, X2, X3 and Y in the previous one ,
> > two
> > or more years as Y. But which year has the closest relationship is not
> > know
> > and this may be one of the analysis aim.
> > Take Year=1995 as an example,
> >  Y_1995 may be related with
> >       X1_1995 , X2_1995 , X3_1995,
> >       X1_1994 , X2_1994 , X3_1994,  Y_1994,   (previous one year)
> >      X1_1993 , X2_1993 , X3_1993, Y_1993      (previous two years)
> >                 ...         ...
> > (previous more years)
> >   Pay attention to the situation that Y itself may also affect its own
> > value
> > of the next several years.
> >    Anybody knows whether R have functions or methods to
> > finish the above task.
> >   I hope i have explained it clearly. Any suggestions or help are
> > greatly
> > appreciated.
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide 
> > http://www.R-project.org/posting-<http://www.r-project.org/posting->
> > guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to