at.vt.val: Variance Transformation Operation for Validation

Description Usage Arguments Value References Examples

View source: R/atrous_vt.R

Description

Variance Transformation Operation for Validation

Usage

1
at.vt.val(data, J, dwt)

Arguments

data

A list of response x and dependent variables dp.

J

Specifies the depth of the decomposition. This must be a number less than or equal to log(length(x),2).

dwt

A class of "at" data. Output from at.vt().

Value

A list of 8 elements: wf, J, boundary, pad, x (data), dp (data), dp.n (variance trasnformed dp), and S (covariance matrix).

References

Z Jiang, A Sharma, and F Johnson. WRR

Examples

 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
data(rain.mon)
data(obs.mon)

##response SPI - calibration
SPI.cal <- SPI.calc(window(rain.mon, start=c(1949,1), end=c(1979,12)),sc=12)

## create paired response and predictors dataset for each station
data.list <- list()
for(id in 1:ncol(SPI.cal)){
  x <- window(SPI.cal[,id], start=c(1950,1), end=c(1979,12))
  dp <- window(obs.mon, start=c(1950,1), end=c(1979,12))
  data.list[[id]] <- list(x=as.numeric(x), dp=matrix(dp, nrow=nrow(dp)))
}

## variance transformation - calibration
dwt.list<- lapply(data.list, function(x) at.vt(x, wf="d4", J=7, pad="zero", boundary="periodic"))

##response SPI - validation
SPI.val <- SPI.calc(window(rain.mon, start=c(1979,1), end=c(2009,12)),sc=12)

## create paired response and predictors dataset for each station
data.list <- list()
for(id in 1:ncol(SPI.val)){
  x <- window(SPI.val[,id], start=c(1980,1), end=c(2009,12))
  dp <- window(obs.mon, start=c(1980,1), end=c(2009,12))
  data.list[[id]] <- list(x=as.numeric(x), dp=matrix(dp, nrow=nrow(dp)))
}

#variance transformation - validation
dwt.list.val<- lapply(1:length(data.list), function(i) at.vt.val(data.list[[i]], J=7, dwt.list[[i]]))

## plot original and reconstrcuted predictors for each station
for(i in 1:length(dwt.list.val)){
  # extract data
  dwt <- dwt.list.val[[i]]
  x <- dwt$x  			        # response
  dp <- dwt$dp			        # original predictors
  dp.n <- dwt$dp.n         # variance transformed predictors
  
  plot.ts(cbind(x,dp))
  plot.ts(cbind(x,dp.n))
  
}

zejiang-unsw/WASP_1.0.0 documentation built on May 6, 2020, 7:49 p.m.