Updating meteorological forecasts, part 1
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
As Mark Twain said “the
art of prophecy is very difficult, especially about the future” (well, actually I am not sure Mark Twain was the first one to say so,
but if you’re interested by that sentence, you can look here). I have been rather surprised to see how Canadians can
be interested in weather, and weather forecasts (see e.g. here for a
first study). For instance, on that website (here),
we can have forecasts of the temperature (but also rain and wind, which
is interesting when you ride a bike) over the next week, almost on an
hourly basis (I show here only GFS forecasts (Global Forecast System,here), which is quite standard, see here or there, but other meteorological models are considered on the website)

So, to look at this problem, Vincent (alias @Vicnent) helped me (again, since he helped me already to get backups of betting websites during the soccer world cup, in June) to make backups of those tables…
- A descriptive study

Here, it is difficult to observe the scatterplot of temperature,
donnees=read.table("http://perso.univ-rennes1.fr/ arthur.charpentier/pred-meteo2.txt") x=donnees$DATE1+donnees$HEURE1/24 x[x<15]=x[x<15]+31 y=donnees$DATE2+donnees$HEURE2/24 y[y<15]=y[y<15]+31 z=y-x h=donnees$TEMPERATURE D=data.frame(x,y,z,h) X0=sort(unique(x)) Y0=sort(unique(y)) Z0=sort(unique(z)) matY.X=matrix(NA,length(X0),length(Y0)) library(splines) for(i in 1:length(X0)){ dd=D[D$x==X0[i],] ax=dd$y ay=dd$h a=data.frame(ax,ay) ra=lm(ay~bs(ax,df=5),data=ba) X=Y0[(Y0>min(ax))&(Y0<max(ax))] iX=which((Y0>min(ax))&(Y0<max(ax))) Y=predict(ra,newdata=data.frame(ax=X)) matY.X[i,iX]=Y }So, let us look at levels of iso-temperature, as a function of the date the prediction is made (the x-axis) and the horizon (the y-axis). First, we we fix the date of the prediction, we get (from the code above)
- Modeling predicted temperatures




library(mgcv) library(splines) REG1=gam(h~s(x,y),data=D,family=gaussian) REG2=lm(h~bs(x)+bs(y),data=D) REG3=gam(h~s(x)+s(y),data=D,family=gaussian) REG4=gam(h~s(x)+s(y),data=D,family=gaussian(link="log")) REG5=gam(h~s(y),data=D,family=gaussian) D$e=residuals(REG5) REG6=gam(e~s(x,y),data=D,family=gaussian)Here is the prediction we had with the additive model

(colors are different because of the log scaling but the shape is similar).
For the component on







* perhaps I should mention that we do not have backups of tables, but backups of html pages... then I use simple linguistic tools available on R to extract the information where it should be....
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.