[R] taylor expansions with real vectors

bilelsan sanbilel at yahoo.fr
Thu Aug 2 02:36:33 CEST 2012


Thanks for specifying the solution.
The deal is that we are faced of vectors. 
Moreover I need to specify them as function of own-lagged
with expansion=1,2, …  ; lag=1, 2, … 
set.seed(1)
E <- cbind(as.vector(rnorm(10)),as.vector(rnorm(10)),as.vector(rnorm(10)))
#or more vectors; here 3 for illustration
Elag <- embed(x=E,2) #for lag = 1

The deal is to obtain All the combinations without duplicates and including
the lags.
The expansion have to lead to:
for expansion = 1 ::>
cbind(Elag[,1],Elag[,2],Elag[,3],Elag[,4],Elag[,5],Elag[,6])
for expansion = 2 ::> we add
cbind(Elag[,1]^2,Elag[,2]^2,Elag[,3]^2,Elag[,4]^2,Elag[,5]^2,Elag[,6]^2);
cbind(Elag[,1]*Elag[,2],
Elag[,1]*Elag[,3],Elag[,1]*Elag[,4],Elag[,1]*Elag[,5],Elag[,1]*Elag[,6]);
cbind(Elag[,2]*Elag[,3],Elag[,2]*Elag[,4],Elag[,2]*Elag[,5],Elag[,2]*Elag[,6]);
cbind(Elag[,3]*Elag[,4]*Elag[,5], … and so on
for expansion = 3 ::> we add
cbind(Elag[,1]^3,Elag[,2]^3,Elag[,3]^3,Elag[,4]^3,Elag[,5]^3,Elag[,6]^3); 
cbind(Elag[,1]^2*Elag[,2],Elag[,1]^2*Elag[,3],Elag[,1]^2*Elag[,4],Elag[,1]^2*Elag[,5],Elag[,1]^2*Elag[,6]);
and so on ...
cbind(Elag[,1]*Elag[,2]*Elag[,3],Elag[,1]*Elag[,2]*Elag[,4],
Elag[,1]*Elag[,2]*Elag[,5], and so on …
for expansion =4 , …

This is what I called Taylor expansion even if we are faced of real vectors.
And I need to keep all these vectors obtained by the expansion considering
other lags (1, 2, 3, …) and other degree of expansion (1, 2, 3, …). 

How could it be automatized?
Thanks for help, I tried for couple of day and I am not able to compute
this. Any advice is very welcome.
Bill



--
View this message in context: http://r.789695.n4.nabble.com/Re-taylor-expansions-with-real-vectors-tp4636948p4638811.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list