[R] traverse through many columns of a matrix in a function

aat adam_6242 at yahoo.com
Thu Feb 1 03:39:21 CET 2007


Hello everyone,

Here is the setup.

z is a 119 x 15 matrix, m_index is a 119 x 5 matrix

What I am trying to do is return the results from fitCopula by sequentially
binding all 15 columns of z to the first column of m_index,
(cbind(z[,1],m_index[,1]),(cbind(z[,2],m_index[,1]), etc.

Unfortunately, my code below only binds z[,1] and m_index[,1] and return the
same result 14 times.

Any ideas on how to implement my idea would be greatly appreciated. Also,
why am I getting the same result 14 times, shouldn't it be 15 since there
are 15 columns in z?


my.cop <- normalCopula(param = 0.5, dim = 2) 
answer <- apply(z[,-1], 2, function(m_index[,1],my.cop)
fitCopula(cbind(z[,-1], m_index[,1]), my.cop, start=0.3), my.cop = my.cop)

Thanks for help.

Adam (aat)

-- 
View this message in context: http://www.nabble.com/traverse-through-many-columns-of-a-matrix-in-a-function-tf3152747.html#a8742152
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list