modwt.vt: Variance Transformation Operation - MODWT

Description Usage Arguments Value References Examples

View source: R/modwt_vt.R

Description

Variance Transformation Operation - MODWT

Usage

1
2
3
4
5
6
7
8
9
modwt.vt(
  data,
  wf,
  J,
  pad,
  boundary,
  vt.opt = c("Sxx", "Cov"),
  cov.opt = c("auto", "pos", "neg")
)

Arguments

data

A list of response x and dependent variables dp.

wf

Name of the wavelet filter to use in the decomposition.

J

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

pad

The method used for extend data to dyadic size. Use "per", "zero", or "sym".

boundary

Character string specifying the boundary condition. If boundary=="periodic" the default, then the vector you decompose is assumed to be periodic on its defined interval, if boundary=="reflection", the vector beyond its boundaries is assumed to be a symmetric reflection of itself.

vt.opt

Options of variance transformation matrix, either "Sxx" or "Cov".

cov.opt

Options of Covariance matrix sign. Use "pos", "neg", or "auto".

Value

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

References

Z Jiang, A Sharma, and F Johnson. WRR

Percival, D. B. and A. T. Walden (2000) Wavelet Methods for Time Series Analysis, Cambridge University Press.

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
###real-world example
x <- window(SPI.12,start=c(1950,1),end=c(2009,12))
dp <- window(obs.mon,start=c(1950,1),end=c(2009,12))
vt.opt = ifelse(0,"Sxx","Cov")

for(id in 5){

  data <- list(x=x[,id],dp=dp)
  dwt <- modwt.vt(data, wf="d4", J=7, pad="zero", boundary="periodic", vt.opt)

  par(mfrow=c(ncol(dp),1),pty="m",mar=c(1,4,1,2))
  for(i in 1:ncol(dp))
    ts.plot(dwt$dp[,i],dwt$dp.n[,i],xlab=NA,col=c("black","red"),lwd=c(2,1))
}
###synthetic example
#frequency, sampled from a given range
fd <- c(3,5,10,15,25,30,55,70,95)

data.SW1 <- data.gen.SW(nobs=512,fp=25,fd=fd)
dwt.SW1 <- modwt.vt(data.SW1, wf="d4", J=7, pad="zero", boundary="periodic",vt.opt)

x.modwt <- waveslim::modwt(dwt.SW1$x, wf = "d4", n.levels = 7,  boundary = "periodic")
dp.modwt <- waveslim::modwt(dwt.SW1$dp[,1], wf = "d4", n.levels = 7,  boundary = "periodic")
dp.vt.modwt <- waveslim::modwt(dwt.SW1$dp.n[,1], wf = "d4", n.levels = 7, boundary = "periodic")

sum(sapply(dp.modwt,var)); var(dwt.SW1$dp[,1])
sum(sapply(dp.vt.modwt,var)); var(dwt.SW1$dp.n[,1])

data <- rbind(sapply(dp.modwt,var)/sum(sapply(dp.modwt,var)),
              sapply(dp.vt.modwt,var)/sum(sapply(dp.vt.modwt,var)))

par(mfrow=c(1,1))
bar <- barplot(data, beside = T, col=c("red","blue"))
lines(x = bar[2,], y = sapply(x.modwt,var)/sum(sapply(x.modwt,var)))
points(x = bar[2,], y = sapply(x.modwt,var)/sum(sapply(x.modwt,var)))

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