Learn R Programming

widals (version 0.6.2)

applystnd.Hs: Standardize Spacial Covariates with Existing Object

Description

Standardize spacial covariates with respect to both the space and time dimensions

Usage

applystnd.Hs(Hs0, x)

Value

An \(n\)* x \(p_s\) matrix.

Arguments

Hs0

Spacial covariates (of interpolation sites). An \(n\)* x \(p_s\) numeric matrix.

x

Spacial standardization object, as created by stnd.Hs.

See Also

stnd.Hst.ls, applystnd.Hst.ls.

Examples

Run this code

n.all <- 21
Hs.all <- cbind(1, rnorm(n.all, 1, 0.1), rnorm(n.all, -200, 21))

ndx.interp <- c(1,3,5)
ndx.support <- I(1:n.all)[ -ndx.interp ]


Hs <- Hs.all[ndx.support, , drop=FALSE]

xsns.obj <- stnd.Hs(Hs)

Hs0 <- Hs.all[ndx.interp, , drop=FALSE]

sHs0 <- applystnd.Hs(Hs0, xsns.obj)
sHs0

xsns.obj$sHs

crossprod(xsns.obj$sHs) / nrow(Hs)

crossprod(sHs0) / nrow(sHs0)


## The function is currently defined as
function (Hs0, x) 
{
    sHs0 <- t((t(Hs0) - x$h.mean)/x$h.sd)
    if (x$intercept) {
        sHs0[, 1] <- 1/sqrt(x$n)
    }
    return(sHs0)
  }

Run the code above in your browser using DataLab