willwerscheid / flashier

A faster and angrier package for EBMF.
https://willwerscheid.github.io/flashier/
Other
10 stars 12 forks source link

Cant initialize only one factor with flash_factor_init #107

Open jean997 opened 1 year ago

jean997 commented 1 year ago
data <- matrix(rnorm(n = 60), ncol = 10, nrow = 6)
init <- list(matrix(rnorm(n = 10), nrow =10, ncol =1), matrix(c(0, 0, 1, 1, 1,1), nrow = 6, ncol = 1))
fl <- flash_init(data = data, var_type =2)
fl <- flash_factors_init(fl, init)

error:

Error in base::colSums(x, na.rm = na.rm, dims = dims, ...) :
'x' must be an array of at least two dimensions

It looks like the issues is in line 65 of residuals_and_R2.R

jean997 commented 10 months ago

Looks like there is the same error from backfit if only one factor is added from flash_greedy

willwerscheid commented 7 months ago

Hi @jean997 sorry i completely missed this issue when it was posted. There is a typo in the code snippet you provided - it should read nrow = 10, ncol = 6 instead of ncol = 10, nrow = 6. That solves the problem for me.