Skip to content
Prev 66064 / 398502 Next

Optimization of constrained linear least-squares problem

you could re-parameterize, e.g.,

EM <- 
c(4.5000,6.0000,10.5000,5.0000,27.0000,20.7500,16.7500,23.6666,38.7500)
W <- array(EM, c(3,3))
d <- c(10, 20, 20)
##############33
fn <- function(x){
    x <- exp(x) / sum(exp(x))
    r <- W%*%x - d
    crossprod(r, r)[1,1]
}
opt <- optim(rnorm(3), fn)
res <- exp(opt$par) / sum(exp(opt$par))
res


I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
     http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "Stefaan Lhermitte" <stefaan.lhermitte at biw.kuleuven.be>
To: <r-help at stat.math.ethz.ch>
Sent: Thursday, March 17, 2005 3:13 PM
Subject: [R] Optimization of constrained linear least-squares problem