fr does not return a scalar.
Nikhil
On Apr 28, 2010, at 3:35 AM, Cz?owiek Kuba wrote:
> Hello,
>
> I have the following problem:
> I have a set of n matrix equations in the form of :
> [b1] = [A] * [b0]
> [b2] = [A] * [b1]
> etc.
> vertical vectors [b0], [b1], ... are GIVEN. We try to estimate
> matrix A. As
> there are many equations (more than cells in matrix A) the system
> has no
> solutions.
> A is transition matrix (stochastic matrix) or markov process, so the
> sum of
> each row = 1 and each entry is probability (aij in <0;1>). I tried to
> estimate A by using constrOptim the following way, but apparently it
> won't
> work on matrices.
>
> fr <- function(x) {
> x%*%matrix(c(2,5,6), 3,1)-matrix(c(5,4,2), 3,1)
> x%*%matrix(c(6,2,3), 3,1)-matrix(c(1,1,1), 3,1)
> x%*%matrix(c(6,1,2), 3,1)-matrix(c(3,4,1), 3,1)
> }
> constrOptim(matrix(c(0.5,0.4,0.1,0.2,0.3,0.5,0.5,0.2,0.3),3,3), fr,
> NULL,
> ui=matrix(c(1,0,0,0,1,0,0,0,1),3,3), ci=matrix(c(-.00001
> ,-.00001,-.00001,-.00001,-.00001,-.00001,-.00001,-.00001,-.00001),
> 3,3))
>
> It produces the following error:
> "Error in ui %*% theta : non-conformable arguments"
>
> Kind regards and thanks for help
> Jacob
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.