[R] embed?
markleeds at verizon.net
markleeds at verizon.net
Fri Apr 3 18:22:18 CEST 2009
Hi kevin: one use ( there are probably many others ) is for use inside
a vector autoregression model where the RHS is
lags of the independent variable. So, x_t is the 3rd column, x_t-1 is the
second, x_t-2 is the third etc.
On Apr 3, 2009, rkevinburton at charter.net wrote:
I have a question on the function 'embed'. I ran the example
x <- 1:10
embed(x, dimension=3)
This gives the output:
[,1] [,2] [,3]
[1,] 3 2 1
[2,] 4 3 2
[3,] 5 4 3
[4,] 6 5 4
[5,] 7 6 5
[6,] 8 7 6
[7,] 9 8 7
[8,] 10 9 8
I don't quite understand the output and why it is useful. First, there are
only 8 rows down from 10 and the first element starts with 3. Of course I
can think of explanations as to what is occuring but I cannot see how this
is useful. I am sure it has application as i see this command used in much
of the source but I just cannot see it now.
The documentation states:
Each row of the resulting matrix consists of sequences x[t], x[t-1], ...,
x[t-dimension+1], where t is the original index of x. If x is a matrix,
i.e., x contains more than one variable, then x[t] consists of the tth
observation on each variable.
This explanation doesn't seem to account for the dimension argument.
Thank you for your comments.
Kevin
______________________________________________
[1]R-help at r-project.org mailing list
[2]https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
[3]http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
References
1. mailto:R-help at r-project.org
2. https://stat.ethz.ch/mailman/listinfo/r-help
3. http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list