Quantcast

Need Help with package "rootSolve"

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Need Help with package "rootSolve"

Olivia.cool
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(r-1)/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)
  lamda-B%*%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
Loading...