| conditional | R Documentation |
Conditionally simulate prediction data from a model object.
conditional(object, ...)
## S3 method for class 'splm'
conditional(
object,
newdata,
output = "newdata",
samples = 1000,
simulate_covparams = FALSE,
...
)
## S3 method for class 'spglm'
conditional(
object,
newdata,
output = "newdata",
type = c("link", "response", "new"),
samples = 1000,
newdata_size,
...
)
object |
A fitted model object. |
... |
Other arguments. Not used (needed for generic consistency). |
newdata |
A data frame or |
output |
The output type, which can be any subset of
|
samples |
The number of conditional simulations. The default is
|
simulate_covparams |
For |
type |
For |
newdata_size |
The |
If "newdata" is in output,
conditional simulations are returned for each row of newdata.
If "beta" is in output,
conditional simulations are returned for each fixed effect
(i.e., element of coef(object). If "object" is in output,
the observed data from object is returned once for each row of
newdata. For example, c("newdata", "beta") returns
the conditional simulations both for newdata and for the
fixed effects. If "cov"/"spcov"/"randcov" is in
output (only available when simulate_covparams = TRUE),
the simulated covariance parameter draws themselves are returned.
If output = "newdata", an a x b matrix of conditional simulations
for each row in newdata, where a is the
number of rows in newdata and b is the number of samples.
If output = "beta", an p x b matrix of conditional simulations for each
element in coef(object), where p is the
number of fixed effects and b is the number of samples.
If output = "object", an n x b matrix of observed data values, where n is the
number of rows in data and b is the number of samples.
If output = "cov"/"spcov"/"randcov"
(simulate_covparams = TRUE only), a (covariance parameter) x b
matrix of the of conditoinal simulations for each covariance parameter, where b is the
number of samples. "cov" returns every covariance parameter,
while "spcov"/"randcov" return just the spatial/random-effect
covariance parameters, respectively.
If output has more than one element, a list is returned with the
respetive elements named according to the relevant output. For example
output = c("newdata", "beta") returns a list with elements
"newdata" and "beta", each containing the relevant output
for output = "newdata" and output = "beta", respectively.
set.seed(0)
spmod <- splm(sulfate ~ 1, data = sulfate, spcov_type = "exponential")
cond <- conditional(spmod, newdata = sulfate_preds)
predict(spmod, sulfate_preds[20, ], se.fit = TRUE)
c("fit_cond" = mean(cond[20, ]), "se.fit_cond" = sd(cond[20, ]))
hist(cond[20, ])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.