A convenience function used to arrange vectorised matrix samples into the correct matrix format for several functions used to specify Markov model. See example_two_state_markov for an example use case. Both a R and C++ implementation are available.

matrix_arrange(samples, type = "rcpp")

Arguments

samples

A list of vectorised matrix samples

type

A character string specifying the approach to use. Currently implemented approaches are "base", and "rcpp" with "rcpp" as the default.

Value

A list of matrices with each matrix representing a single sample.

Examples

matrix_samples <- list(VGAM::rdiric(1:5, c(88, 12)), VGAM::rdiric(1:5, c(8, 92))) # Default usage matrix_arrange(matrix_samples)
#> [[1]] #> [,1] [,2] #> [1,] 0.84342242 0.1565776 #> [2,] 0.07292427 0.9270757 #> #> [[2]] #> [,1] [,2] #> [1,] 0.90233022 0.09766978 #> [2,] 0.04882021 0.95117979 #> #> [[3]] #> [,1] [,2] #> [1,] 0.86451370 0.1354863 #> [2,] 0.07360987 0.9263901 #> #> [[4]] #> [,1] [,2] #> [1,] 0.89066732 0.1093327 #> [2,] 0.06245647 0.9375435 #> #> [[5]] #> [,1] [,2] #> [1,] 0.84868762 0.1513124 #> [2,] 0.08050864 0.9194914 #>
# R implementation matrix_arrange(matrix_samples, type = "base")
#> [[1]] #> [,1] [,2] #> [1,] 0.84342242 0.1565776 #> [2,] 0.07292427 0.9270757 #> #> [[2]] #> [,1] [,2] #> [1,] 0.90233022 0.09766978 #> [2,] 0.04882021 0.95117979 #> #> [[3]] #> [,1] [,2] #> [1,] 0.86451370 0.1354863 #> [2,] 0.07360987 0.9263901 #> #> [[4]] #> [,1] [,2] #> [1,] 0.89066732 0.1093327 #> [2,] 0.06245647 0.9375435 #> #> [[5]] #> [,1] [,2] #> [1,] 0.84868762 0.1513124 #> [2,] 0.08050864 0.9194914 #>
# Rcpp implementation matrix_arrange(matrix_samples, type = "rcpp")
#> [[1]] #> [,1] [,2] #> [1,] 0.84342242 0.1565776 #> [2,] 0.07292427 0.9270757 #> #> [[2]] #> [,1] [,2] #> [1,] 0.90233022 0.09766978 #> [2,] 0.04882021 0.95117979 #> #> [[3]] #> [,1] [,2] #> [1,] 0.86451370 0.1354863 #> [2,] 0.07360987 0.9263901 #> #> [[4]] #> [,1] [,2] #> [1,] 0.89066732 0.1093327 #> [2,] 0.06245647 0.9375435 #> #> [[5]] #> [,1] [,2] #> [1,] 0.84868762 0.1513124 #> [2,] 0.08050864 0.9194914 #>