8000 mpm_collapse bug - NaN column in output · Issue #166 · jonesor/Rage · GitHub 8000
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
mpm_collapse bug - NaN column in output #166
Open
@jonesor

Description

@jonesor

I have found a bug in mpm_collapse that I am struggling with.
Sometimes, the output matrix from mpm_collapse has NaN values in the final column, which causes problems in analyses. What causes this behaviour? Can we fix it?

Here's a clunky but replicatable example:

A <- matrix(c(0, 0.996209935189834, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
           0, 0, 0.991584639707654, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
           0, 0, 0, 0.981367788179782, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
           0, 0, 0, 0, 0.959006021461268, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
           0.395469318032286, 0, 0, 0, 0, 0.911050886198815, 0, 0, 0, 0, 
           0, 0, 0, 0, 0, 0, 0.427337118548192, 0, 0, 0, 0, 0, 
           0.81275654994096, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.459469795638312, 0, 
           0, 0, 0, 0, 0, 0.630395869496673, 0, 0, 0, 0, 0, 0, 0, 0, 
           0.49155469074513, 0, 0, 0, 0, 0, 0, 0, 0.358122270025713, 0, 0, 0, 
           0, 0, 0, 0, 0.523257244553273, 0, 0, 0, 0, 0, 0, 0, 0, 
           0.101736892726593, 0, 0, 0, 0, 0, 0, 0.554226366194208, 0, 0, 0, 
           0, 0, 0, 0, 0, 0, 0.00618162578413958, 0, 0, 0, 0, 0, 
           0.584100587303554, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
           1.21341309051636e-05, 0, 0, 0, 0, 0.612514861948583, 0, 0, 0, 0, 
           0,
70EF
 0, 0, 0, 0, 0, 0, 1.1461992080595e-11, 0, 0, 0, 
           0.639107841724659, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
           4.47646892042388e-25, 0, 0, 0.663529428707613, 0, 0, 0, 0, 0, 0, 0, 
           0, 0, 0, 0, 0, 0, 6.45892956429893e-55, 0, 0.685448388953421, 0, 0, 
           0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2.50204082860751e-121, 
           0.704559797110107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
           byrow = FALSE, ncol = 16) 

A_split <- Rage::mpm_split(A)

stages <- list()
stages[[1]]<-1:2
stages[[2]]<-3:4
stages[[3]]<-5:6
stages[[4]]<-7:8
stages[[5]]<-9:10
stages[[6]]<-11:12
stages[[7]]<-13:14
stages[[8]]<-15:16

collapsed_A <- Rage::mpm_collapse(matU = A_split$matU, matF = A_split$matF, collapse = stages)

collapsed_A$matU
#>           [,1]      [,2]     [,3]      [,4]        [,5]         [,6]
#> [1,] 0.5106187 0.0000000 0.000000 0.0000000 0.000000000 0.000000e+00
#> [2,] 0.4833367 0.5066909 0.000000 0.0000000 0.000000000 0.000000e+00
#> [3,] 0.0000000 0.4638608 0.487273 0.0000000 0.000000000 0.000000e+00
#> [4,] 0.0000000 0.0000000 0.378056 0.3935600 0.000000000 0.000000e+00
#> [5,] 0.0000000 0.0000000 0.000000 0.1345444 0.092731003 0.000000e+00
#> [6,] 0.0000000 0.0000000 0.000000 0.0000000 0.000547206 1.213399e-05
#> [7,] 0.0000000 0.0000000 0.000000 0.0000000 0.000000000 1.327660e-16
#> [8,] 0.0000000 0.0000000 0.000000 0.0000000 0.000000000 0.000000e+00
#>              [,7] [,8]
#> [1,] 0.000000e+00  NaN
#> [2,] 0.000000e+00  NaN
#> [3,] 0.000000e+00  NaN
#> [4,] 0.000000e+00  NaN
#> [5,] 0.000000e+00  NaN
#> [6,] 0.000000e+00  NaN
#> [7,] 4.476469e-25  NaN
#> [8,] 2.760065e-79  NaN

Created on 2021-08-11 by the reprex package (v2.0.1)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0