Quantile regression split plots

293 views Asked by At

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

1

There are 1 answers

4
CPak On BEST ANSWER

If you want to run quantreg::rq on different sets of your data, replace

data$ahmAnn~data$Days

with

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")