I have the following precipitation data for 1951:
dat.1951=c(122,122,122,122,122,122,122,122,122,122,122,121,121,121,121,120,119,119,117,117,117,115,115,115,114,112,112,111,110,109,106,105,104,103,102,99,97,95,91,89,88,86,84,83,83,82,82,79,77,77,76,74,74,72,72,71,70,69,66,65,64,61,61,58,56,56,54,53,51,49,48,47,46,46,46,45,42,40,39,38,37,36,36,35,34,33,33,32,30,30,29,28,28,27,25,25,23,22,21,20,20,20,20,20,19,19,18,18,18,16,16,15,15,15,15,15,14,14,14,14,14,14,14,14,14,14,14,13,13,12,12,11,11,11,11,11,11,11,11,11,11,11,11,11,11,10,10,10,9,8,8,8,8,8,8,8,8,8,8,8,8,7,7,6,6,6,6,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,1,1)
I want to match this data. I break this data into 2 areas (head and tail). One, where the points are less than 100 (head), and the rest (for> 100) is the tail. I could match the exponential part of the head (see code below). For the tail, I want to fit the curve and want to build both parts on the same plot along with the data. Can anyone help?
dat.1951<-dat.1951[dat.1951 > 0] dat.1951.tail<-dat.1951[dat.1951 >= 100] dat.1951.head<-dat.1951[dat.1951 < 100] x.head<-seq(1,length(dat.1951.head)) log.data<-log(dat.1951.head) idf.head<-data.frame(x.head,dat.1951.head) idf.head$dat.1951.head<-log(idf.head$dat.1951.head) model=lm(idf.head$dat.1951.head ~ idf.head$x.head,data=idf.head) summary(model) plot(dat.1951.head) lines(idf.head$x.head,exp(fitted(model)),col="blue")