[R-sig-Geo] Prediction with SpTimer

Franklin Tchakounte tchafros at gmail.com
Sat Jul 12 19:09:11 CEST 2014


Hello,

using spTimer i have written the following code to predict in 2015
based on observed data from 2010, 2011, 2012 and 2014. The data file
is attached into this mail.

# Beginning of the code

library(sp)
library(spacetime)
library(gstat)
library(spTimer)
library(timeDate)
setwd("/home//tchakounte//Bureau//Bureau.6.5.2014//nao")
dataSet <- read.csv("DTPP.csv", sep=";")
str(dataSet)
# drop the last two empty rows
#dataSet <- dataSet[1:195,]
#str(dataSet)
dataSet
coords<-as.matrix(unique(cbind(dataSet[,2:3])))
coords
time.data<-spT.time(t.series=39,segment=1)
post.ar <- spT.Gibbs(formula=Population~1, data=dataSet,
coords=coords, model="GP", scale.transform="SQRT")
print(post.ar)
names(post.ar)

# Temporal prediction/forecast for the GP model
 # 1. In the unobserved locations

dataSet1 <- read.csv("DTP11.csv", sep=";")
str(dataSet1)
dataSet1
# define forecast coordinates
fore.coords<-as.matrix(unique(cbind(dataSet1[,2:3])))
 # Two-step ahead forecast, i.e., in day 61 and 62
 # in the unobserved locations using output from spT.Gibbs
   set.seed(11)
   fore.gp <- predict(post.ar, newdata=dataSet1,
newcoords=fore.coords, type="temporal", foreStep=1, tol.dist=0.2,
time.data=time.data)
   print(fore.gp)
   names(fore.gp)
 # Display of the results
   fore.gp$Mean

# End

I obtained in 2015 the following data. But they are far from data in
2014 (pop2014 column) and to the reality . What can be the reason? Is
it possible to improve these results? is the code not good?

9091.872
12556.05
8597.584
13149.06
13274.52
12901.98
5943.395
12714.68
12244.41
14581.41
10488.06
10456.81
10456.72
10618.93
10868.03
9995.434
10011.75
9852.718
10038.11
10813.48
10588.04
10531.63
10320.15
13652.01
9871.999
12379.98
12971.01
12034.11
11955.15
14497.78
10812.44
10714.2
10360.53
10632.32
10596.62
10256.28
10279.86
9967.04
10362.7

Thanks in advance.

Franklin Tchakounté
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DTPP.csv
Type: text/csv
Size: 7162 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20140712/a70f79e0/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DTP11.csv
Type: text/csv
Size: 1320 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20140712/a70f79e0/attachment-0001.bin>


More information about the R-sig-Geo mailing list