Hst.sumup | R Documentation |
Calculate the covariance matrix of all model covariates
Hst.sumup(Hst.ls, Hs = NULL, Ht = NULL)
Hst.ls |
Space-time covariates. A list of length |
Hs |
Spacial covariates. An |
Ht |
Temporal covariates. An |
Important: The order of the arguments in this function is NOT the same as in the returned covariance matrix. The order in the covariance matrix is the same as in other functions in this package: Hs
, Ht
, Hst.ls
.
A (p_s+p_t+p_st)
x (p_s+p_t+p_st)
numeric, symmetrix, non-negative definite matrix.
tau <- 20
n <- 10
Ht <- cbind(sin(1:tau), cos(1:tau))
Hs <- cbind(rnorm(10), rnorm(n, 5, 49))
Hst.ls <- list()
for(tt in 1:tau) {
Hst.ls[[tt]] <- cbind(rnorm(n, 1, 0.1), rnorm(n, -200, 21))
}
Hst.sumup(Hst.ls, Hs, Ht)
########### standardize all covariates
x1 <- stnd.Hst.ls(Hst.ls, NULL)$sHst.ls
x2 <- stnd.Hs(Hs, NULL, FALSE)$sHs
x3 <- stnd.Ht(Ht, n)
Hst.sumup(x1, x2, x3)
## The function is currently defined as
function (Hst.ls, Hs = NULL, Ht = NULL)
{
tau <- length(Hst.ls)
if(tau < 1) { tau <- nrow(Ht) }
if(is.null(tau)) { tau <- 10 ; cat("tau assumed to be 10.", "\n") }
n <- nrow(Hst.ls[[1]])
if(is.null(n)) { n <- nrow(Hs) }
big.sum <- 0
for (i in 1:tau) {
if (!is.null(Ht)) {
Ht.mx <- matrix(Ht[i, ], n, ncol(Ht), byrow = TRUE)
}
else {
Ht.mx <- NULL
}
big.sum <- big.sum + crossprod(cbind(Hs, Ht.mx, Hst.ls[[i]]))
}
return(big.sum)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.