1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
# fields is a package for analysis of spatial data written for
# the R software environment .
# Copyright (C) 2018
# University Corporation for Atmospheric Research (UCAR)
# Contact: Douglas Nychka, nychka@ucar.edu,
# National Center for Atmospheric Research,
# PO Box 3000, Boulder, CO 80307-3000
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# test of Wendland covariance and stationary.taper.cov
suppressMessages(library(fields))
options( echo=FALSE)
test.for.zero.flag<- 1
set.seed(123)
x1<- matrix( runif(2*20), ncol=2)
x2<- matrix( runif(2*10), ncol=2)
fields.rdist.near( x1,x2, delta=.75)-> look
temp<- matrix( NA, nrow(x1),nrow(x2))
temp[ look$ind] <- look$ra
temp2<- rdist( x1, x2)
temp2[ temp2> .75] <- NA
#set.panel( 2,1) ; image.plot( temp); image.plot( temp2)
temp[ is.na( temp)]<- 0
temp2[ is.na( temp2)]<- 0
test.for.zero( temp, temp2)
# test of constructing covariance matrix
# and also versions of Wendland function
# default taper is wendland k=2.
DD<- rdist( x1,x2)
temp<- Wendland2.2(DD, theta=.8)
temp2<- Wendland( DD, theta=.8, k=2, dimension=2)
test.for.zero( temp, temp2)
stationary.taper.cov( x1,x2, Taper="Wendland2.2",
Taper.args= list( theta=.8), spam.format=FALSE )-> look
temp0<- look
stationary.taper.cov( x1,x2, Taper="Wendland2.2",
Taper.args= list( theta=.8), spam.format=TRUE )-> look
temp1<- spam2full( look)
test.for.zero( temp1, temp0)
stationary.taper.cov( x1,x2, Taper="Wendland",
Taper.args= list( theta=.8, k=2, dimension=2),
spam.format=TRUE )-> look
temp1b<- spam2full( look)
temp2<- Wendland2.2(DD, theta=.8) * Exponential(DD)
temp3<- wendland.cov(x1,x2, k=2, theta=.8) * Exponential(DD)
temp4<- Wendland(DD, k=2, dimension=2, theta=.8)* Exponential(DD)
test.for.zero( temp1, temp0, rel=FALSE)
test.for.zero( temp1b, temp0, rel=FALSE)
test.for.zero( temp2, temp0, rel=FALSE)
test.for.zero( temp2, temp3,rel=FALSE)
test.for.zero( temp2, temp4,rel=FALSE)
set.seed( 256)
rv<- runif( nrow(x2))
# test of multiply
stationary.taper.cov( x1, x2, C= rv)-> look
temp2<-stationary.taper.cov( x1,x2)
(as.matrix(temp2))%*%(rv)-> look2
test.for.zero( look, look2)
temp2%*%(rv)-> look2
test.for.zero( look, look2)
cat( "Done with testing Wendland family", fill=TRUE)
options( echo=TRUE)
|