R/An.hat.est.R

Defines functions An.hat.est

An.hat.est <- function(Omega, x, y, n, p, q){

  An.hat <- matrix(0, nrow = p*(q+1), ncol = p*(q+1))

  An.hat[seq_len(p), seq_len(p)] <- Omega * n
  tmp1 <-  matrix(0, nrow = p, ncol = p*q)
  tmp2 <-  matrix(0, nrow = p*q, ncol = p*q)
  for(i in 1:n){
    tmp1 <- tmp1 + kroneckerC(Omega, x[i,, drop = F])
    tmp2 <- tmp2 + kroneckerC(Omega, crossprod(x[i,,drop = F]))
  }
  An.hat[seq_len(p), (p+1):(p*(q+1))] <- tmp1
  An.hat[(p+1):(p*(q+1)), 1:p] <- t(tmp1)
  An.hat[(p+1):(p*(q+1)), (p+1):(p*(q+1))] <- tmp2

  return(An.hat)
}
PengWu12245/EcoPleio documentation built on Jan. 7, 2020, 12:23 a.m.