Description Usage Arguments Value Note Examples
A helper function that appends a dummy value to a given slots in Data
class object, if and only if the total number of observations (as indicated
by object@nObs
) equals to 1
. Otherwise, the object
is not changed.
1 | h_jags_add_dummy(object, where, dummy = 0)
|
object |
( |
where |
( |
dummy |
( |
A Data
object with slots updated with dummy number.
The main motivation behind this function is related to the JAGS
.
If there is only one observation, the data is not passed correctly to
JAGS
, i.e. e.g. x
and y
are treated like scalars in the data file.
Therefore it is necessary to add dummy values to the vectors in this case
As we don't change the number of observations (nObs
), this addition of
zeros doesn't affect the results of JAGS
computations.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # Create some data of class 'Data'
my_data <- Data(
x = 0.1,
y = 0,
doseGrid = c(0.1, 0.5)
)
my_data_2 <- Data(
x = c(0.1, 0.5),
y = c(0, 1),
doseGrid = c(0.1, 0.5)
)
# Append dummy to `x` and `y`.
h_jags_add_dummy(my_data, where = c("x", "y"))
# Append dummy to `x` and `y`. No effect as `my_data_2@nObs != 1`.
h_jags_add_dummy(my_data_2, where = c("x", "y"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.