[R] optimization w.r.t matrix

David Winsemius dwinsemius at comcast.net
Tue Oct 5 21:40:59 CEST 2010


On Oct 5, 2010, at 2:46 PM, QiJun Fung wrote:

> Does any one know how to optimize the following function w.r.t to
> beta? The difficulty here is the beta is a matrix not a vector. and f
> is also a function of beta and an element of the objective function. I
> just want to know for this complicated situation, is there any
> packages or function to estimate matrix beta? All the packages I found
> can only estimate the vector beta.

What is preventing you from passing a vector and then treating that  
vector as a matrix within the function? Matrices in R are basically  
folded vectors after all.


> Thanks very much!
>
object.fn <- function(beta)
       {
         # Perhaps
        b2 <- as.matrix(beta, nrow=3, ncol=3)
          p <- M
          f  <-solve(diag(p)+w*Omega) %*% t(data.hist) %*% b2/
                 (norm(solve(diag(p)+w*Omega)%*%t(data.hist),"F"))
         # return
            sum(diag( (data.hist-b2 %*% t(f) ) %*% t(data.hist-b2 %*%  
t(f) ) ) )+
            w*t(b2) %*% b2 %*% t(f) %*% Omega %*% f

       }

(I am taking as implied that the this will return a scalar or an  
object that can be properly minimized.)
>

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list