如何删除高10%分位数的值

时间:2018-09-05 17:52:14

标签: r quantile non-linear-regression

具有以下数据(摘自:https://www.r-bloggers.com/first-steps-with-non-linear-regression-in-r/):

#simulate some data
set.seed(20160227)
x<-seq(0,50,1)
y<-((runif(1,10,20)*x)/(runif(1,0,10)+x))+rnorm(51,0,1)
#for simple models nls find good starting values for the parameters even if it throw a warning
m<-nls(y~a*x/(b+x))
#get some estimation of goodness of fit
cor(y,predict(m))

[1] 0.9496598

#plot
plot(x,y)
lines(x,predict(m),lty=2,col="red",lwd=3)

enter image description here

如何删除代表y〜x的比例的高10%的值?

使用以下代码,可以绘制代表90%分位数的线。我所缺少的是如何删除位于90%分位数(绿线)上方的所有数据(y〜x)

# prepare data
xy <- as.data.table(cbind(x,y)) 
xy <- xy[-1, ]

# fit line 
fit.nlrq.09 <-  nlrq(y ~ SSmicmen(x, Vm, K), data = xy, tau = 0.90) 
lines(fitted(fit.nlrq.09) ~ x, xy, col=3)

enter image description here

0 个答案:

没有答案