
Dear everyone,
I wanted to solve elements in matrices like this:
LAMDA=BMB'
In my matrices, LAMDA is a r*r diagonal matrix, there is r unknowns to be solved, B is a lower triangle matrix with diagonal elements equal to one, so in B there is r(r1)/2 unknowns to be solved, M is a known matrix.
I tried to use package rootSolve, here is my code:
littledog<function(x){
B<matrix(c(1,0,x[1],1),2,2,byrow=T)
lamda<diag(c(x[2],x[3]),2,2)
lamdaB%*%matrix(c(1,0.5,0.5,2),2,2,byrow=T)%*%t(B)
}
x<multiroot(littledog,c(0,0,0))$root
x
report:
Error in stode(y, times, func, parms = parms, ...) :
The number of derivatives returned by 'func() (4must equal the length of the initial conditions vector (3)
Could anybody help me out where I did wrong?
Thanks a lot!
Olivia
