Skip to contents

This function takes an anglemania_object containing a list of FBMs and calculates the mean of every element. If the list is empty or the FBMs have different dimensions, it throws an error.

Usage

big_mat_list_mean(angl)

Arguments

angl

An anglemania_object containing the list of FBMs. In this case, the FBMs are the angle matrices computed in factorise.

Value

A new FBM object containing the mean values.

Examples

# Create FBMs
mat1 <- matrix(1:9, nrow = 3)
mat2 <- matrix(1:9, nrow = 3)

fbm1 <- bigstatsr::FBM(nrow = nrow(mat1), ncol = ncol(mat1), init = mat1)
fbm2 <- bigstatsr::FBM(nrow = nrow(mat2), ncol = ncol(mat2), init = mat2)

# Create weights
weights <- c(batch1 = 0.5, batch2 = 0.5)

# Create the list of FBMs
fbm_list <- list(batch1 = fbm1, batch2 = fbm2)

# Construct the anglemania_object
angl <- new(
  "anglemania_object",
  weights = weights,
  matrix_list = fbm_list
)
big_mat_list_mean(angl)
#> A Filebacked Big Matrix of type 'double' with 3 rows and 3 columns.