[R] non-negative least-squares

Simon Wood simon at stats.gla.ac.uk
Tue Mar 2 10:20:49 CET 2004


I think pcls will do what you want. You'll need to explicitly set up the
constraint matrix, since pcls is designed to deal with general linear
inequality constraints (i.e. it will do more than just non-negativity).
Also the penalty matrix/matrices for pcls would be t(L)%*%L, I think.

btw, there's a pre-release version of mgcv 1.0 at

http://www.stats.gla.ac.uk/~simon/simon/mgcv.html

which has a less obscure way of supplying the penalty matrices to pcls,
and might therefore be a bit easier to use. (Also features gamms, tensor
product smoothing, p-splines and stuff.)

best,
Simon

> 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
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list