遵循非线性分位数回归的工作流程似乎有效。但是我不知道如何绘制结果曲线。
顺便说一句:我更喜欢使用函数 graphics::curve() 而不是 graphics::lines()
require(quantreg)
# load sample data
dat <- DNase
# introduce variable
x <- DNase$conc
y <- DNase$density
# introduce function
f <- function(a, b, x) {(a*x/(b+x))}
# fit the model
fm0 <- nls(log(y) ~ log(f(a,b,x)), dat, start = c(a = 1, b = 1))
# fit a nonlinear least-square regression
fit <- nls(y ~ f(a,b,x), dat, start = coef(fm0))
# receive coeffientes
co <- coef(fit)
a=co[1]
b=co[2]
# plot
plot(y~x)
# add curve
curve((a*x/(b+x)), add=T)
# then fit the median using nlrq
dat.nlrq <- nlrq(y ~ SSlogis(x, Asym, mid, scal), data=dat, tau=0.5)
# add curve
???
编辑:我正在寻找的是一种绘制公式的各种分位数回归的方法,例如 a*x/(b+x)。插入公式让我想到了将什么作为“开始”参数的问题
dat.nlrq.075 <- nlrq(formula=fit, data = dat, start=???, tau = 0.75)