Fit the spatial covariate-augmented overdispersed Poisson factor model

SpaCOAP(
  X_count,
  Adj_sp,
  H,
  Z = matrix(1, nrow(X_count), 1),
  offset = rep(0, nrow(X_count)),
  rank_use = 5,
  q = 15,
  epsELBO = 1e-08,
  maxIter = 30,
  verbose = TRUE,
  add_IC_inter = FALSE,
  seed = 1,
  algo = 1
)

Arguments

X_count

a count matrix, the observed count matrix with shape n-by-p.

Adj_sp

a sparse matrix, the weighted adjacency matrix;

H

a n-by-d matrix, the covariate matrix with low-rank regression coefficient matrix;

Z

an optional matrix, the fixed-dimensional covariate matrix with control variables; default as a full-one column vector if there is no additional covariates.

offset

an optional vector, the offset for each unit; default as full-zero vector.

rank_use

an optional integer, specify the rank of the regression coefficient matrix; default as 5.

q

an optional string, specify the number of factors; default as 15.

epsELBO

an optional positive vlaue, tolerance of relative variation rate of the envidence lower bound value, defualt as '1e-8'.

maxIter

the maximum iteration of the VEM algorithm. The default is 30.

verbose

a logical value, whether output the information in iteration.

add_IC_inter

a logical value, add the identifiability condition in iterative algorithm or add it after algorithm converges; default as FALSE.

seed

an integer, set the random seed in initialization, default as 1;

algo

an optional integer taking value 1 0r 2, select the algorithm used, default as 1, representing variational EM algorithm.

Value

return a list including the following components:

  • F - the predicted factor matrix;

  • B - the estimated loading matrix;

  • bbeta - the estimated low-rank large coefficient matrix;

  • alpha0 - the estimated regression coefficient matrix corresponing to Z;

  • invLambda - the inverse of the estimated variances of error;

  • eta - the estimated spatial autocorrelation parameter;

  • S - the approximated posterior covariance for each row of F;

  • ELBO - the ELBO value when algorithm stops;

  • ELBO_seq - the sequence of ELBO values.

  • time_use - the running time in model fitting of SpaCOAP;

Details

None

References

Liu W, Zhong Q. High-dimensional covariate-augmented overdispersed poisson factor model. Biometrics. 2024 Jun;80(2):ujae031.

See also

None

Examples

width <- 20; height <- 15; p <- 100
d <- 20; k <- 3; q <- 6; r <- 3
datlist <- gendata_spacoap(width=width, height=height, p=p, d=20, k=k, q=q, rank0=r)
fitlist <- SpaCOAP(X_count=datlist$X, Adj_sp = datlist$Adj_sp, H= datlist$H, Z = datlist$Z, q=6, rank_use=3)
#> Calculate initial values...
#> Model fitting...
#> iter = 2, ELBO= 476439166591111.562500, dELBO=221860.275639 
#> iter = 3, ELBO= 476439166600595.812500, dELBO=0.000000 
str(fitlist)
#> List of 10
#>  $ F        : num [1:300, 1:6] -1.11 0.157 -1.377 1.443 0.603 ...
#>  $ B        : num [1:100, 1:6] 0.238 1.168 -0.901 -1.394 -2.052 ...
#>  $ bbeta    : num [1:100, 1:20] 0.127 2.45 -1.982 2.09 -1.111 ...
#>  $ alpha    : num [1:100, 1:3] 1.6629 1.6303 -0.0133 1.6839 2.3901 ...
#>  $ invLambda: num [1:100, 1] 0.566 0.558 0.492 0.569 0.286 ...
#>  $ eta      : num 0.516
#>  $ S        : num [1:6, 1:6, 1:300] 0.01128 -0.000497 0.000162 0.000692 0.000644 ...
#>  $ ELBO     : num 4.76e+14
#>  $ ELBO_seq : num [1:2] -2.15e+09 4.76e+14
#>  $ time_use : Named num 0.03
#>   ..- attr(*, "names")= chr "elapsed"