Answer to: Creating a smoother profile of a set of number using R
Score: 0
It appears more logical to me to perform an isotonic regression; Details section from help file, see help(isoreg):
The algorithm determines the convex minorant
𝑚
(
𝑥
)
m(x) of the cumulative data (i.e., cumsum(y)) which is piecewise linear and the result is
𝑚
′
(
𝑥
)
m
′
(x), a step function with level changes at locations where the convex
𝑚
(
𝑥
)
m(x) touches the cumulative data polygon and changes slope.
as.stepfun() returns a stepfun object which can be more parsimonious.
dat = c(3, 4, 2, 10, 1, 23, 11, 44)
ir = isoreg(dat)
> ir
Isotonic regression from isoreg(x = dat),
with 5 knots / breaks at obs.nr. 1 3 5 7 8 ;
initially ordered 'x'
and further components List of 4
$ x : num [1:8] 1 2 3 4 5 6 7 8
$ y : num [1:8] 3 4 2 10 1 23 11 44
$ yf: num [1:8] 3 3 3 5.5 5.5 17 17 44
$ yc: num [1:9] 0 3 7 9 19 20 43 54 98
plot(ir$x, ir$yf, type='b')
points(ir$x, ir$y, col='red')
View Question ↗
Question
Parent Entity
Score: 3 • Views: 106
Site: stackoverflow
SaaS Metrics