Extract parameters' draws

extract_draws(obj, draws)

Arguments

obj

Array/Vector/Matrix of draws (cf. first dimension) or list of it.

draws

Vector of draws to extract.

Value

Dataframe with columns: Draw, Index, Value and Parameter.

Examples

x <- rnorm(1e3)
X <- matrix(x, ncol = 10)
a <- array(rnorm(80), dim = c(10, 2, 2, 2))
extract_draws(x, sample(1:length(x), 10))
#>    Draw Index      Value Parameter
#> 1   326    NA  0.7711702          
#> 2   257    NA  0.5220327          
#> 3   105    NA -1.3224836          
#> 4   654    NA  0.9458170          
#> 5   746    NA  1.3818006          
#> 6   132    NA -0.2083272          
#> 7   859    NA  0.8845094          
#> 8   338    NA -0.1364428          
#> 9   435    NA -0.2627182          
#> 10  312    NA -0.5341900          
extract_draws(X, sample(1:nrow(X), 10)) %>% head()
#>   Draw Index      Value Parameter
#> 1   29     1 -1.8653027          
#> 2   31     1  1.0523220          
#> 3   62     1 -0.1456682          
#> 4   93     1  2.0142505          
#> 5   68     1  1.3568983          
#> 6   73     1 -0.8230297          
extract_draws(a, sample(1:10, 5)) %>% head()
#>    Draw       Value Index Parameter
#> 3     3 -1.33252770    NA   [1,1,1]
#> 5     5  0.02511390    NA   [1,1,1]
#> 6     6 -0.75371502    NA   [1,1,1]
#> 9     9 -0.01135488    NA   [1,1,1]
#> 10   10 -0.66968870    NA   [1,1,1]
#> 13    3  1.22714959    NA   [2,1,1]
extract_draws(list(x = x, X = X, a = a), 1:10) %>% head()
#>   Draw Index      Value Parameter
#> 1    1    NA  0.9735376         x
#> 2    2    NA -0.8452533         x
#> 3    3    NA  1.1172942         x
#> 4    4    NA  0.8076302         x
#> 5    5    NA  0.1668433         x
#> 6    6    NA -1.1330682         x