[R] Monotonic regression in R??
Prof Brian D Ripley
ripley at stats.ox.ac.uk
Sun Mar 4 09:32:14 CET 2001
Here is a solution using C code:
library(MASS)
isoreg <- function(x, y)
{
ord <- order(x)
y <- y[ord]
nd <- length(ord)
Z <- .C("VR_mds_fn",
as.double(y), yf=as.double(y), as.integer(nd),
ssq = double(1), as.integer(order(ord)-1), as.double(x),
as.integer(0), as.integer(0), g=double(0), as.integer(0),
PACKAGE = "MASS")
list(x = x[ord], y = y, fitted = Z$yf, RSS = Z$ssq)
}
I have not checked what happens it there are ties in the x's.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list