knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(knitr)
The GeoRTS package provides a set of tools for reconstruction (by interpolation) of geographical time series
Install the stable version from CRAN:
install.packages("GeoRTS")
or install the development version from Github:
# install.packages("devtools") devtools::install_github("InstitutoInvestigacionesEconomicasPUCE/GeoRTS")
First we need to carge the data, so we use:
library(GeoRTS) library(gridExtra) data(rts)
Then we have in our environment five new objects: TS
, positions.TS
, weights.TS
, positions.RTS
, weights.RTS
library(stlplus) library(dplyr) library(ggplot2) library(reshape2) library(gridExtra) library(leaflet) library(highcharter) load(file="func_borr.RData") load(file="rts.RData")
Where TS
is a multivariate "ts" object, which has missing values:
kable(TS[10:25,])
Then applyinng rts_clean
function to TS
, by consider the parameter of seasonality 12:
TS_clean = rts_clean(TS,seasonality = 12) kable(TS_clean[10:25,])
Using the rts_plotClean
we can plot the original and cleaned function:
pl = list() for (i in seq(dim(TS)[2])) { pl[[i]] = rts_plotClean(TS,i) } grid.arrange(grobs=pl,nrow=dim(TS)[2])
To reconstruct (by IDW) unknownn data of time series associated to positions.RTS
(latitude and longitud in meters) we use geoRTS
function, that consider an aproximation based in convex combination of original time series in TS
, considering the distance between TS
given by positions.TS
, also it could be consider some factors as weight.TS
related with the local geographical influence of time series.
RTS = geoRts(TS_clean,positions.TS,weights.TS,positions.RTS,weights.RTS) kable(RTS[10:25,])
Then we could plot both series (original and reconstructed) with the function rts_plotGroup
rts_plotGroup(TS_clean,RTS)
Finally we could represent the date in a map with function rts_map
rts_map(positions.TS,positions.RTS,scale=10^4,weights.TS,weights.RTS)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.