[R] non-negative least-squares

Willem Vervoort w.vervoort at acss.usyd.edu.au
Mon Mar 1 23:28:51 CET 2004


Hi all,
I am trying to do an inversion of electromagnetic data with non-negative 
least squares method (Tikhonov regularisation) and have got it 
programmed in S-Plus. However I am trying to move all my scripts from 
S-Plus to R.

Is there an equivalent to nnls.fit in R?
I think this can be done with pcls? Right?

S-Plus script: A, L and data are matrices, lambda is a vector of 
possible lambda (smoothing) values

> "nntik"<-function(A,L,data,lambda)
> {
> H<-rbind(A,lambda*L)
> i<-1:(nrow(L)+length(data))
> q<-ifelse(i<=length(data),data[i],0)
> nntik<-nnls.fit(H,q)
> return(nntik)
> }

I think this is the same as what pcls states:


Willem

-- 
Dr R.W. Vervoort
McCaughey Senior Lecturer Hydrology and Catchment Management			
Faculty of Agriculture, Food and Natural Resources
Rm 503, Watt Bldg.
http://www.agric.usyd.edu.au/mccaughey

Postal:
Bldg A03
The University of Sydney, NSW, 2006

phone: +61 (2) 9351 8744
fax:   +61 (2) 9351 5108
e-mail: w.vervoort at acss.usyd.edu.au




More information about the R-help mailing list