Defines functions haar.aggregate

Documented in haar.aggregate

#' Get data at all scales.
#' This function takes a matrix x of Poisson counts, nind by 2^k, and returns a nind by (2*2^k)-2 matrix that sums up columns of x at different scales. The last two columns of the aggregate are the sums of the first half of x and the sums of the second half. This function is needed to estimate the pi-s by aggregating data from multiple regions.
haar.aggregate= function(x){
  if(is.vector(x)){dim(x)<- c(1,length(x))} #convert x to matrix
  y = x
  k = log2(ncol(x))
  for(i in 1:(k-1)){
    nc = ncol(x)
    oddcols = ((1:nc) %% 2)==1
    x = x[,!oddcols,drop="FALSE"]+x[,oddcols,drop="FALSE"]
    y = cbind(y,x)
shimlab/HMTree documentation built on May 29, 2019, 9:25 p.m.