suppressWarnings(library(fields))
## Loading required package: spam
## Loading required package: grid
## Spam version 1.4-0 (2016-08-29) 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
# some examples using the O3 data 

data( ozone2)
x<- ozone2$lon.lat
y<- ozone2$y[16,]
good<- !is.na( y)
x<- x[good,]
y<- y[good]

# EDA plot of data
set.panel()
## plot window will lay out plots in a 1 by 1 matrix
quilt.plot( x,y)
US( add= TRUE, lwd=1)

obj1<- Tps( x,y)
# summary of fit
print( obj1)
## Call:
## Tps(x = x, Y = y)
##                                                
##  Number of Observations:                147    
##  Number of parameters in the null space 3      
##  Parameters for fixed spatial drift     3      
##  Model degrees of freedom:              74.6   
##  Residual degrees of freedom:           72.4   
##  GCV estimate for sigma:                9.276  
##  MLE for sigma:                         8.307  
##  MLE for rho:                           958000 
##  lambda                                 7.2e-05
##  User supplied rho                      NA     
##  User supplied sigma^2                  NA     
## Summary of estimates: 
##                  lambda      trA      GCV     shat -lnLike Prof converge
## GCV        7.203669e-05 74.61258 174.7194  9.27563     609.3412        6
## GCV.model            NA       NA       NA       NA           NA       NA
## GCV.one    7.203669e-05 74.61258 174.7194  9.27563           NA        6
## RMSE                 NA       NA       NA       NA           NA       NA
## pure error           NA       NA       NA       NA           NA       NA
## REML       5.653414e-04 41.20301 188.3494 11.64287     600.9061        5
# four diagnostic plots
set.panel( 2,2)
## plot window will lay out plots in a 2 by 2 matrix
plot( obj1)

set.panel()
## plot window will lay out plots in a 1 by 1 matrix
# fitted.surface
surface( obj1)