Skip to contents

An example dataset compatible with the model file from tar_jags_example_file(). The output has a .join_data element so the true value of beta from the simulation is automatically appended to the beta rows of the summary output.

Usage

tar_jags_example_data(n = 10L)

Format

A list with the following elements:

  • n: integer, number of data points.

  • x: numeric, covariate vector.

  • y: numeric, response variable.

  • true_beta: numeric of length 1, value of the regression coefficient beta used in simulation.

  • .join_data: a list of simulated values to be appended to as a .join_data column in the output of targets generated by functions such as tar_jags_rep_summary(). Contains the regression coefficient beta (numeric of length 1) and prior predictive data y (numeric vector).

Arguments

n

Integer of length 1, number of data points.

Value

List, dataset compatible with the model file from tar_jags_example_file(). The output has a .join_data

element so the true value of beta from the simulation is automatically appended to the beta rows of the summary output.

Details

The tar_jags_example_data() function draws a JAGS dataset from the prior predictive distribution of the model from tar_jags_example_file(). First, the regression coefficient beta is drawn from its standard normal prior, and the covariate x is computed. Then, conditional on the beta draws and the covariate, the response vector y is drawn from its Normal(x * beta, 1) likelihood.

Examples

tar_jags_example_data()
#> $n
#> [1] 10
#> 
#> $x
#>  [1] -1.0000000 -0.7777778 -0.5555556 -0.3333333 -0.1111111  0.1111111
#>  [7]  0.3333333  0.5555556  0.7777778  1.0000000
#> 
#> $y
#>  [1]  1.16985815 -0.39366265 -0.07419443 -0.52507478 -0.62216342 -0.16486405
#>  [7]  0.87271840 -1.63088828  0.14557360  1.41821488
#> 
#> $.join_data
#> $.join_data$beta
#> [1] 0.7643165
#> 
#>