1

I have few years of daily rainfall data for a particular region. To get an insight of extreme rainfall events,I used quantile regression (quantreg package) in R. The plot for entire days is shown below. What I want is to split the regression line in the middle (or some other point) and fit for first and second half of the data separately to see the difference.

Here is how I used quantreg:

plot(data$ahmAnn~data$Days, type="p", pch=20,cex=.4, col="gray50",
                                        xlab="Days", ylab="Rainfall")
qr <- abline(rq(data$ahmAnn~data$Days,tau=.99),col="red")

Quantile regression plot

4

1 回答 1

1

如果要quantreg::rq在不同的数据集上运行,请替换

data$ahmAnn~data$Days

x <- 10
stopifnot(x <= nrow(data))

set1 <- data[1:X,]
abline(rq(set1$ahmAnn~set1$Days,tau=.99),col="red")

set2 <- data[X:nrow(data),]
abline(rq(set2$ahmAnn~set2$Days,tau=.99),col="red")
于 2017-09-12T09:22:42.763 回答