traverse through many columns of a matrix in a function

classic Classic list List threaded Threaded
1 message Options
aat
Reply | Threaded
Open this post in threaded view
|

traverse through many columns of a matrix in a function

aat
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)