Hals.ses: Effective Standard Errors

Description Usage Arguments Value Examples

View source: R/Hals.ses.R

Description

Calculate the ALS so-called 'effective standard errors'

Usage

1
Hals.ses(Z, Hs, Ht, Hst.ls, rho, reg, b.lag, test.rng)

Arguments

Z

Space-time data. A τ x n numeric matrix.

Hs

Spacial covariates (of supporting sites). An n x p_s numeric matrix.

Ht

Temporal covariates (of supporting sites). A τ x p_t numeric matrix.

Hst.ls

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

rho

ALS signal-to-noise ratio (SNR). A non-negative scalar.

reg

ALS regularizer. A non-negative scalar.

b.lag

ALS lag. A scalar integer, typically -1 (a-prior), or 0 (a-posteriori).

test.rng

Temporal test range. A vector of temporal indices of the model test range.

Value

A named list.

estimates

A p_s+p_t+p_st x 2 matrix, each row giving the ALS partial slope estimate/prediction at time τ, and the 'effective standard error (prediction error)' for the partial slope.

inv.LHH

A (p_s+p_t+p_st) x (p_s+p_t+p_st) matrix. This is the (ALS predicted) covariate precision matrix at time τ.

ALS.g

The ALS gain at time τ.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Please see the example in H.als.b

## The function is currently defined as
function (Z, Hs, Ht, Hst.ls, rho, reg, b.lag, test.rng) 
{
    tau <- nrow(Z)
    xALS <- H.als.b(Z = Z, Hs = Hs, Ht = Ht, Hst.ls = Hst.ls, 
        rho = rho, reg = reg, b.lag = b.lag, Hs0 = NULL, Ht0 = NULL, 
        Hst0.ls = NULL)
    rmse <- sqrt(mean((Z[test.rng, ] - xALS$Z.hat[test.rng, ])^2))
    rmse
    als.se <- rmse * sqrt(xALS$ALS.g) * sqrt(diag(xALS$inv.LHH))
    return(list(estimates = cbind(xALS$B[tau, ], als.se), inv.LHH = xALS$inv.LHH, 
        ALS.g = xALS$ALS.g))
  }

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