Extract Samples From a dynamitefit
Object as a Data Table
Source: R/as_data_table.R
as.data.table.dynamitefit.Rd
Provides a data.table
representation of the posterior samples of the model
parameters. See as.data.frame.dynamitefit()
for details.
Usage
# S3 method for class 'dynamitefit'
as.data.table(
x,
keep.rownames = FALSE,
row.names = NULL,
optional = FALSE,
types = NULL,
parameters = NULL,
responses = NULL,
times = NULL,
groups = NULL,
summary = FALSE,
probs = c(0.05, 0.95),
include_fixed = TRUE,
...
)
Arguments
- x
[
dynamitefit
]
The model fit object.- keep.rownames
[
logical(1)
]
Not used.- row.names
Ignored.
- optional
Ignored.
- types
[
character()
]
Type(s) of the parameters for which the samples should be extracted. See details of possible values. Default is all values listed in details except spline coefficientsomega
. This argument is mutually exclusive withparameters
.- parameters
[
character()
]
Parameter(s) for which the samples should be extracted. Possible options can be found with functionget_parameter_names()
. Default is all parameters of specific type for all responses. This argument is mutually exclusive withtypes
.- responses
[
character()
]
Response(s) for which the samples should be extracted. Possible options are elements ofunique(x$priors$response)
, and the default is this entire vector. Ignored if the argumentparameters
is supplied.omega_alpha
, andomega_psi
. See alsoget_parameter_types()
.- times
[
double()
]
Time point(s) to keep. IfNULL
(the default), all time points are kept.- groups
[
character()
]
Group name(s) to keep. IfNULL
(the default), all groups are kept.- summary
[
logical(1)
]
IfTRUE
, returns posterior mean, standard deviation, and posterior quantiles (as defined by theprobs
argument) for all parameters. IfFALSE
(default), returns the posterior samples instead.- probs
[
numeric()
]
Quantiles of interest. Default isc(0.05, 0.95)
.- include_fixed
[
logical(1)
]
IfTRUE
(default), time-varying parameters for1:fixed
time points are included in the output asNA
values. IfFALSE
, fixed time points are omitted completely from the output.- ...
Ignored.
See also
Model outputs
as.data.frame.dynamitefit()
,
as_draws_df.dynamitefit()
,
coef.dynamitefit()
,
confint.dynamitefit()
,
dynamite()
,
get_code()
,
get_data()
,
get_parameter_dims()
,
get_parameter_names()
,
get_parameter_types()
,
ndraws.dynamitefit()
,
nobs.dynamitefit()
Examples
data.table::setDTthreads(1) # For CRAN
as.data.table(
gaussian_example_fit,
responses = "y",
types = "beta",
summary = FALSE
)
#> parameter value time category group response type .draw .iteration
#> <char> <num> <int> <char> <int> <char> <char> <int> <int>
#> 1: beta_y_z 1.958289 NA <NA> NA y beta 1 1
#> 2: beta_y_z 1.972815 NA <NA> NA y beta 2 2
#> 3: beta_y_z 1.956837 NA <NA> NA y beta 3 3
#> 4: beta_y_z 1.949148 NA <NA> NA y beta 4 4
#> 5: beta_y_z 1.962168 NA <NA> NA y beta 5 5
#> ---
#> 196: beta_y_z 1.960357 NA <NA> NA y beta 196 96
#> 197: beta_y_z 1.967019 NA <NA> NA y beta 197 97
#> 198: beta_y_z 1.968887 NA <NA> NA y beta 198 98
#> 199: beta_y_z 1.960676 NA <NA> NA y beta 199 99
#> 200: beta_y_z 1.961960 NA <NA> NA y beta 200 100
#> .chain
#> <int>
#> 1: 1
#> 2: 1
#> 3: 1
#> 4: 1
#> 5: 1
#> ---
#> 196: 2
#> 197: 2
#> 198: 2
#> 199: 2
#> 200: 2