Load Packages
library(sm) # for sm.density in diagnostics
## Package 'sm', version 2.2-5.5: type help(sm) for summary information
library(leaps) # to provide combinations
library(MPV) # for calculating PRESS
library(akima) # for interp to smooth for plotting
library(fields) # for surface to plot surface plot
## Loading required package: spam
## Loading required package: dotCall64
## Loading required package: grid
## Spam version 2.2-0 (2018-06-19) is loaded.
## Type 'help( Spam)' or 'demo( spam)' for a short introduction
## and overview of this package.
## Help for individual functions is also obtained by adding the
## suffix '.spam' to the function name, e.g. 'help( chol.spam)'.
##
## Attaching package: 'spam'
## The following objects are masked from 'package:base':
##
## backsolve, forwardsolve
## Loading required package: maps
## See www.image.ucar.edu/~nychka/Fields for
## a vignette and other supplements.
library(locfit) # for fitting local polynomial
## locfit 1.5-9.1 2013-03-22
library(MASS)
##
## Attaching package: 'MASS'
## The following object is masked from 'package:MPV':
##
## cement
## The following object is masked from 'package:sm':
##
## muscle
library(VGAM) # useful for multynomial fit
## Loading required package: stats4
##
## Attaching package: 'stats4'
## The following object is masked from 'package:spam':
##
## mle
## Loading required package: splines
library(nnet) # to fit multinomial regression
library(verification)
## Loading required package: boot
##
## Attaching package: 'boot'
## The following objects are masked from 'package:VGAM':
##
## logit, simplex
## The following object is masked from 'package:MPV':
##
## motor
## The following object is masked from 'package:sm':
##
## dogs
## Loading required package: CircStats
##
## Attaching package: 'CircStats'
## The following objects are masked from 'package:VGAM':
##
## dcard, rcard
## Loading required package: dtw
## Loading required package: proxy
##
## Attaching package: 'proxy'
## The following object is masked from 'package:spam':
##
## as.matrix
## The following objects are masked from 'package:stats':
##
## as.dist, dist
## The following object is masked from 'package:base':
##
## as.matrix
## Loaded dtw v1.20-1. See ?dtw for help, citation("dtw") for use in publication.
##
## Attaching package: 'verification'
## The following object is masked from 'package:VGAM':
##
## exponential
library(latex2exp) # LaTeX math formulas to R's
library(maps) # useful for graphs function map
library(rgdal) # for converting projection of coordinates
## Loading required package: sp
## rgdal: version: 1.3-4, (SVN revision 766)
## Geospatial Data Abstraction Library extensions to R successfully loaded
## Loaded GDAL runtime: GDAL 2.2.3, released 2017/11/20
## Path to GDAL shared files: C:/Users/DELL/Documents/R/win-library/3.5/rgdal/gdal
## GDAL binary built with GEOS: TRUE
## Loaded PROJ.4 runtime: Rel. 4.9.3, 15 August 2016, [PJ_VERSION: 493]
## Path to PROJ.4 shared files: C:/Users/DELL/Documents/R/win-library/3.5/rgdal/proj
## Linking to sp version: 1.3-1
library(ggplot2) # for plotting spatial map
library(reshape2) # for using the melt function (Convert an object into a molten data frame)
library(scales) # for Visualization spatial map
library(spBayes) # for bayesian kriging
## Loading required package: coda
##
## Attaching package: 'coda'
## The following object is masked from 'package:VGAM':
##
## nvar
## Loading required package: magic
## Loading required package: abind
## Loading required package: Formula
library(geoR)
## --------------------------------------------------------------
## Analysis of Geostatistical Data
## For an Introduction to geoR go to http://www.leg.ufpr.br/geoR
## geoR version 1.7-5.2.1 (built on 2016-05-02) is now loaded
## --------------------------------------------------------------
library(mclust)
## Package 'mclust' version 5.4.1
## Type 'citation("mclust")' for citing this R package in publications.
##
## Attaching package: 'mclust'
## The following object is masked from 'package:maps':
##
## map
library(tree) # classification and regression trees
library(randomForest) #Random Forest
## randomForest 4.6-14
## Type rfNews() to see new features/changes/bug fixes.
##
## Attaching package: 'randomForest'
## The following object is masked from 'package:ggplot2':
##
## margin
library(RColorBrewer) # Color schemes for maps
library(Hmisc) # Add minor tick marks
## Loading required package: lattice
##
## Attaching package: 'lattice'
## The following object is masked from 'package:boot':
##
## melanoma
## Loading required package: survival
##
## Attaching package: 'survival'
## The following object is masked from 'package:boot':
##
## aml
##
## Attaching package: 'Hmisc'
## The following object is masked from 'package:fields':
##
## describe
## The following objects are masked from 'package:base':
##
## format.pval, units
library(wesanderson)
library(cluster) # To perform clustering of the Extremes
##
## Attaching package: 'cluster'
## The following object is masked from 'package:maps':
##
## votes.repub
library(kohonen) #required to perform som
##
## Attaching package: 'kohonen'
## The following object is masked from 'package:mclust':
##
## map
## The following object is masked from 'package:maps':
##
## map
Quilt plotting function
Quilt_plotting=function(lon, lat, ypred, lon1, lat1, yob,type=""){
if (type=="binary"){
par(mfrow=c(3,1))
quilt.plot(lon, lat,ypred$fit,xlab="Longitude (m)",ylab="Latitude (m)",main='Posterior Binary Precipitation on DEM Grid',zlim=range(ypred$fit,yob))
grid(col="gray70",lty=2)
US(add=TRUE, col="gray50", lwd=2,xlim=range(-125,-100))
box()
quilt.plot(lon1, lat1,yob,xlab="Longitude (m)",ylab="Latitude (m)",main='Observed Binary Precipitation',zlim=range(ypred$fit,yob))
grid(col="gray70",lty=2)
US(add=TRUE, col="gray50", lwd=2,xlim=range(-125,-100))
box()
quilt.plot(lon, lat,ypred$se,xlab="Longitude (m)",ylab="Latitude (m)",main='Standard Error on DEM Grid')
grid(col="gray70",lty=2)
US(add=TRUE, col="gray50", lwd=2,xlim=range(-125,-100))
box()
} else{
par(mfrow=c(3,1))
quilt.plot(lon, lat,ypred$fit,xlab="Longitude (m)",ylab="Latitude (m)",main='Posterior Precipitation on DEM Grid (mm)',zlim=range(ypred$fit,yob))
grid(col="gray70",lty=2)
US(add=TRUE, col="gray50", lwd=2,xlim=range(-125,-100))
box()
quilt.plot(lon1, lat1,yob,xlab="Longitude (m)",ylab="Latitude (m)",main='Observed Precipitation (mm)',zlim=range(ypred$fit,yob))
grid(col="gray70",lty=2)
US(add=TRUE, col="gray50", lwd=2,xlim=range(-125,-100))
box()
quilt.plot(lon, lat,ypred$se,xlab="Longitude (m)",ylab="Latitude (m)",main='Standard Error on DEM Grid (mm)')
grid(col="gray70",lty=2)
US(add=TRUE, col="gray50", lwd=2,xlim=range(-125,-100))
box()
}
}