stnd.Hst.ls: Standardize Space-Time Covariates

Description Usage Arguments Value See Also Examples

View source: R/stnd.Hst.ls.R

Description

Standardize spacio-temporal covariates with respect to both the spacial and time dimensions

Usage

1
stnd.Hst.ls(Hst.ls, Hst0.ls = NULL)

Arguments

Hst.ls

Space-time covariates (of supporting sites). A list of length τ, each element should be a numeric n x p_st matrix.

Hst0.ls

Space-time covariates (of interpolation sites). A list of length τ, each element should be a numeric n* x p_st matrix.

Value

A named list.

sHst.ls

A list of length τ, each element a numeric n x p_st matrix.

sHst0.ls

A list of length τ, each element a n* x p_st matrix

h.mean

The covariates' mean over space-time.

h.sd

The covariates' standard deviation over space-time.

See Also

stnd.Ht, stnd.Hs, applystnd.Hst.ls.

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
	
##### Please see the examples in Hst.sumup

## The function is currently defined as
function (Hst.ls, Hst0.ls = NULL) 
{
    tau <- length(Hst.ls)
    big.sum <- 0
    for (i in 1:tau) {
        big.sum <- big.sum + apply(Hst.ls[[i]], 2, mean)
    }
    h.mean <- big.sum/tau
    sHst.ls <- list()
    big.sum.mx <- 0
    for (i in 1:tau) {
        sHst.ls[[i]] <- t(t(Hst.ls[[i]]) - h.mean)
        big.sum.mx <- big.sum.mx + crossprod(sHst.ls[[i]])
    }
    cov.mx <- big.sum.mx/tau
    sqrtXX <- 1/sqrt(diag(cov.mx))
    for (i in 1:tau) {
        sHst.ls[[i]] <- t(t(sHst.ls[[i]]) * sqrtXX)
    }
    sHst0.ls <- NULL
    if (!is.null(Hst0.ls)) {
        sHst0.ls <- list()
        for (i in 1:tau) {
            sHst0.ls[[i]] <- t((t(Hst0.ls[[i]]) - h.mean) * sqrtXX)
        }
    }
    ls.out <- list(sHst.ls = sHst.ls, sHst0.ls = sHst0.ls, h.mean = h.mean, 
        h.sd = 1/sqrtXX)
    return(ls.out)
  }

widals documentation built on Dec. 8, 2019, 1:07 a.m.