[R] optim or nlm with matrices

Ahmad Abu Hammour hammour at msn.com
Fri Apr 26 20:37:03 CEST 2002


Hi,
I have the following hypothetical optimization problem:
-det(t(x-A%*%x1)%*%(x-A%*%x1))
where A,x,x1 are matrices. A coefficients and x and x1 are variable matrices or vectors.
I tried to apply optim and nlm functions but I kept receive the following massage:
Error in A%*%x1 : non-conformable arguments.
The massage appears even the -det() can be calculated and the dimensions are checked.
here is my example although there might be no solution for the optimization problem.
A=A
myfn=function(A){
x=matrix(c(1.8,0),byrow=T)
x1=matrix(c(.8,1.8),byrow=T)
-det((t(x)-t(x1)%*%A)%*%(x-A%*%x1))
}
A=matrix(c(1,.3,2,-1.2),byrow=T,nrow=2)
optim(A,myfn)
Another question regarding optimization:
is there any chance that I can find a function or package that can do a constrained optimization such as: -det(x-A*x1-B*x2)' (x-A*x1-B*x2))  
subject to  
p-f(A,B,...)=0, where f denotes a function.
Thank you for your help in advance.
Ahmad Abu Hammour
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://stat.ethz.ch/pipermail/r-help/attachments/20020426/3776f60f/attachment.html


More information about the R-help mailing list