[This article was first published on Freakonometrics - Tag - R-english, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
In order to study the average temperature it is natural to look at the linear (assuming that it is linear, but I proved that it could reasonably be assumed as linear in the paper) regression, i.e. least square regression, which gives the expected value. But if we care about extremes, or almost extremes, it is natural to look at quantile regression.
For instance, below, the green line is the least square regression, the red one is 97.5% quantile, and the blue on the 2.5% quantile regression.
tmaxparis=read.table("temperature/TG_SOUID100845.txt", skip=20,sep=",",header=TRUE) head(tmaxparis) Dparis=as.Date(as.character(tmaxparis$DATE),"%Y%m%d") Tparis=as.numeric(tmaxparis$TG)/10 Tparis[Tparis==-999.9]=NA I=sample(1:length(Tparis),size=5000,replace=FALSE) plot(Dparis[I],Tparis[I],col="grey") abline(lm(Tparis~Dparis),col="green") library(quantreg) abline(rq(Tparis~Dparis,tau=.025),col="blue") abline(rq(Tparis~Dparis,tau=.975),col="red")
Now, if we look at the slope for different quantile level (Fig 6 in the paper, here, but on minimum daily temperature, here I look at average daily temperature), the interpretation is different.
s=0 COEF=SD=rep(NA,199) for(i in seq(.005,.995,by=.005)){ s=s+1 REG=rq(Tparis~Dparis,tau=i) COEF[s]=REG$coefficients[2] SD[s]=summary(REG)$coefficients[2,2] }
s=0 plot(seq(.005,.995,by=.005),COEF,type="l",ylim=c(0.00002,.00008)) for(i in seq(.005,.995,by=.005)){ s=s+1 segments(i,COEF[s]-2*SD[s],i,COEF[s]+2*SD[s],col="grey") } REG=lm(Tparis~Dparis) COEFlm=REG$coefficients[2] SDlm=summary(REG)$coefficients[2,2] abline(h=COEFlm,col="red") abline(h=COEFlm-2*SDlm,lty=2,lw=.6,col="red") abline(h=COEFlm+2*SDlm,lty=2,lw=.6,col="red")
Note also that the story is different for minimal temperature (mentioned in the paper) compared with that study, made here on average daily temperature (see comments)… This is not a major breakthrough in climate research, but this is all I got…
To leave a comment for the author, please follow the link and comment on their blog: Freakonometrics - Tag - R-english.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.