[R] Optimization of constrained linear least-squares problem

From: Stefaan Lhermitte <stefaan.lhermitte_at_biw.kuleuven.be>
Date: Fri 18 Mar 2005 - 01:13:25 EST

Dear R-ians,

I want to perform an linear unmixing of image pixels in fractions of pure endmembers. Therefore I need to perform a constrained linear least-squares problem that looks like :

min || Cx - d || ² where sum(x) = 1.

I have a 3x3 matrix C, containing the values for endmembers and I have a 3x1 column vector d (for every pixel in the image). In theory my x values should all be in the (0,1) interval but I don't want to force them so I can check the validity of my solution. I just want to calculate the x values. Can anyone help me with this problem? I've been checking the optim, optimize, constrOptim and nlm help files, burt I don't understand it very well. Wich function should I use for my problem? I did a first test using optim:

# Make my C matrix

EM<- c(4.5000,6.0000,10.5000,5.0000,27.0000,20.7500,16.7500,23.6666,38.7500) C <- array(EM, c(3,3))

# Take an arbitrary d

d<-c(10, 20, 20)

# Define the function

 fr <- function(x) {



# Perform the optimization


But it did not work. I got the eror couldn't find function. Can anyone tell me what functyion I should use for my problem and how should I program it?

Thanx in advance,

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Mar 18 01:28:12 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:50 EST