Last data update: 2014.03.03

R: Median polish Spline.
splineMPSTR Documentation

Median polish Spline.

Description

The "splineMPST" is dessigned to represent the variability of effects of spatio - temporal data on a surface, from robust median polish algoritm and planar interpolation.

Usage

splineMPST(Grid,Ef_t,MPST,eps, maxiter)

Arguments

Grid

grid with the coordinates in space "x", "y", "z", where will be viewed trend.

Ef_t

it's the temporal scenary to look trend.

MPST

object of class ConstructMPst.

eps

real number greater than 0, default 0.01. A tolerance for convergence.

maxiter

the maximum number of iterations, default 10.

Value

Data frame, where columns show the trend in each spatio - temporal location.

References

Berke, O. (2001). Modified median polish kriging and its application to the wolfcamp - aquifer data. Environmetrics, 12(8):731-748.[link]

Cressie, N. (1993). Statistics for spatial data. Wiley series in probability and statistics.[link]

Examples

## Not run:
data(Metadb)
x<-matrix(0,1,37)
for(i in 1:37){
 x[,i] <- 2007 + (seq(0, 36)/12)[i]
}
x<-as.Date (as.yearmon(x), frac = 1)
time = as.POSIXct(x, tz = "GMT")
length(time)

MPST<-ConstructMPst(Metadb[,-c(1:4)],time,pts=Metadb[,2:4],Delta=c(7,6,5))

MpSTData<-MedianPolishM(MPST,eps=0, maxiter=5, na.rm=TRUE)

data(DemMeta)
xy = SpatialPoints(Metadb[,2:4],CRS(proj4string(DemMeta)))

data(HZRMeta)
proj4string(HZRMeta)<-CRS(proj4string(DemMeta))

polygon1 = polygons(HZRMeta)
Gridxy<- spsample(polygon1, cellsize=2000, n=300,"regular")

Grid<-data.frame(Gridxy,over(Gridxy,DemMeta))
colnames(Grid)<-c("East", "North","height")

TendenciaGrilla<-splineMPST(Grid,Ef_t=time[10:15],MPST,eps=0.01, maxiter=2)

IDs = paste("ID",1:length(TendenciaGrilla[,5]))
mydata = data.frame(values = TendenciaGrilla[,5], ID=IDs)
wind.ST1 = STFDF(SpatialPixels(Gridxy),time[10:15],mydata)
stplot(wind.ST1,col.regions=bpy.colors(40),par.strip.text = list(cex=0.7)
      ,main="Spline median polish: Monthly Precipitation")
## End(Not run)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(STMedianPolish)
Loading required package: maptools
Loading required package: sp
Checking rgeos availability: TRUE
Loading required package: reshape2
Loading required package: spacetime
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/STMedianPolish/splineMPST.Rd_%03d_medium.png", width=480, height=480)
> ### Name: splineMPST
> ### Title: Median polish Spline.
> ### Aliases: splineMPST
> 
> ### ** Examples
> 
> ## Not run:
> data(Metadb)
> x<-matrix(0,1,37)
> for(i in 1:37){
+  x[,i] <- 2007 + (seq(0, 36)/12)[i]
+ }
> x<-as.Date (as.yearmon(x), frac = 1)
> time = as.POSIXct(x, tz = "GMT")
> length(time)
[1] 37
> 
> MPST<-ConstructMPst(Metadb[,-c(1:4)],time,pts=Metadb[,2:4],Delta=c(7,6,5))
   |                                                                               |                                                                      |   0%   |                                                                               |==                                                                    |   3%   |                                                                               |====                                                                  |   5%   |                                                                               |======                                                                |   8%   |                                                                               |========                                                              |  11%   |                                                                               |=========                                                             |  14%   |                                                                               |===========                                                           |  16%   |                                                                               |=============                                                         |  19%   |                                                                               |===============                                                       |  22%   |                                                                               |=================                                                     |  24%   |                                                                               |===================                                                   |  27%   |                                                                               |=====================                                                 |  30%   |                                                                               |=======================                                               |  32%   |                                                                               |=========================                                             |  35%   |                                                                               |==========================                                            |  38%   |                                                                               |============================                                          |  41%   |                                                                               |==============================                                        |  43%   |                                                                               |================================                                      |  46%   |                                                                               |==================================                                    |  49%   |                                                                               |====================================                                  |  51%   |                                                                               |======================================                                |  54%   |                                                                               |========================================                              |  57%   |                                                                               |==========================================                            |  59%   |                                                                               |============================================                          |  62%   |                                                                               |=============================================                         |  65%   |                                                                               |===============================================                       |  68%   |                                                                               |=================================================                     |  70%   |                                                                               |===================================================                   |  73%   |                                                                               |=====================================================                 |  76%   |                                                                               |=======================================================               |  78%   |                                                                               |=========================================================             |  81%   |                                                                               |===========================================================           |  84%   |                                                                               |=============================================================         |  86%   |                                                                               |==============================================================        |  89%   |                                                                               |================================================================      |  92%   |                                                                               |==================================================================    |  95%   |                                                                               |====================================================================  |  97%   |                                                                               |======================================================================| 100%
> 
> MpSTData<-MedianPolishM(MPST,eps=0, maxiter=5, na.rm=TRUE)
> 
> data(DemMeta)
> xy = SpatialPoints(Metadb[,2:4],CRS(proj4string(DemMeta)))
> 
> data(HZRMeta)
> proj4string(HZRMeta)<-CRS(proj4string(DemMeta))
> 
> polygon1 = polygons(HZRMeta)
> Gridxy<- spsample(polygon1, cellsize=2000, n=300,"regular")
> 
> Grid<-data.frame(Gridxy,over(Gridxy,DemMeta))
> colnames(Grid)<-c("East", "North","height")
> 
> TendenciaGrilla<-splineMPST(Grid,Ef_t=time[10:15],MPST,eps=0.01, maxiter=2)
   |                                                                               |                                                                      |   0%   |                                                                               |============                                                          |  17%   |                                                                               |=======================                                               |  33%   |                                                                               |===================================                                   |  50%   |                                                                               |===============================================                       |  67%   |                                                                               |==========================================================            |  83%   |                                                                               |======================================================================| 100%
> 
> IDs = paste("ID",1:length(TendenciaGrilla[,5]))
> mydata = data.frame(values = TendenciaGrilla[,5], ID=IDs)
> wind.ST1 = STFDF(SpatialPixels(Gridxy),time[10:15],mydata)
> stplot(wind.ST1,col.regions=bpy.colors(40),par.strip.text = list(cex=0.7)
+       ,main="Spline median polish: Monthly Precipitation")
> ## End(Not run)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>