Select/Filter parameters from precis/extract data frames
Arguments
- d
data frame. A data frame returned by
stom::precis()
orstom::extract()
.- pars
Character vector of parameter names to retrieve.
Examples
fp = system.file("cases", "wine_network", "wine2_normal_first_level2.RDS", package="stom")
m = readRDS(fp)
# Posterior summary data frame
d = precis( m, depth=3 )
#> Warning: The draws object contained no variables with unreserved names. No summaries were computed.
#> Warning: Unknown or uninitialised column: `variable`.
#> Warning: Unknown or uninitialised column: `variable`.
get_pars( d, c("Int", "Int_raw") )
#> data frame with 0 columns and 0 rows
# Posterior sample data frame
d = extract( m )
get_pars( d, "Int, Int_raw" )
#> # A tibble: 4,000 × 7
#> `Int_raw[1]` `Int_raw[2]` `Int_raw[3]` `Int[1,1]` `Int[2,1]` `Int[1,2]`
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1.59 -0.237 1.83 1.59 1.83 -0.237
#> 2 1.40 -0.600 1.74 1.40 1.74 -0.600
#> 3 1.85 -0.0834 1.89 1.85 1.89 -0.0834
#> 4 1.65 -0.370 2.05 1.65 2.05 -0.370
#> 5 1.58 -0.271 1.75 1.58 1.75 -0.271
#> 6 1.72 -0.146 2.02 1.72 2.02 -0.146
#> 7 1.78 -0.224 1.85 1.78 1.85 -0.224
#> 8 1.65 -0.0572 1.68 1.65 1.68 -0.0572
#> 9 1.60 -0.620 1.85 1.60 1.85 -0.620
#> 10 1.26 -0.644 1.62 1.26 1.62 -0.644
#> # ℹ 3,990 more rows
#> # ℹ 1 more variable: `Int[2,2]` <dbl>
# Simulation list
d = list(
params = list(
B_AE = 2,
E = matrix(0, 2, 2),
kappa = 1:5,
subj = list(
sigma_subj = 1:3,
Rho = matrix(1, 2, 2),
Alpha_TD = 1
)
)
)
get_pars(d, "B_AE")
#> [1] 2
get_pars( d, "kappa, Rho" )
#> $kappa
#> [1] 1 2 3 4 5
#>
#> $Rho
#> [,1] [,2]
#> [1,] 1 1
#> [2,] 1 1
#>