| bplm | R Documentation |
Computes a bayesian (hierarchical) piecewise linear model based on a Markov chain Monte Carlo sampler. The function automatically creates the fixed and random part of the regression model.
bplm(
data,
dvar,
pvar,
mvar,
model = c("W", "H-M", "B&L-B"),
contrast_level = c("first", "preceding"),
contrast_slope = c("first", "preceding"),
trend = TRUE,
level = TRUE,
slope = TRUE,
random_trend = FALSE,
random_level = FALSE,
random_slope = FALSE,
fixed = NULL,
random = NULL,
update_fixed = NULL,
...
)
## S3 method for class 'sc_bplm'
print(x, digits = 3, ...)
## S3 method for class 'sc_bplm'
export(
object,
caption = NA,
footnote = NA,
filename = NA,
round = 2,
nice = TRUE,
...
)
data |
A single-case data frame. See |
dvar |
Character string with the name of the dependent variable. Defaults to the attributes in the scdf file. |
pvar |
Character string with the name of the phase variable. Defaults to the attributes in the scdf file. |
mvar |
Character string with the name of the measurement time variable. Defaults to the attributes in the scdf file. |
model |
Model used for calculating the dummy parameters (see Huitema &
McKean, 2000). Default is |
contrast_level |
Either "first", "preceding" or a contrast matrix. If NA contrast_level is a copy of contrast. |
contrast_slope |
Either "first", "preceding" or a contrast matrix. If NA contrast_level is a copy of contrast. |
trend |
A logical indicating if a trend parameters is included in the model. |
level |
A logical indicating if a level parameters is included in the model. |
slope |
A logical indicating if a slope parameters is included in the model. |
random_trend |
If TRUE, includes a random trend effect. |
random_level |
If TRUE, includes a random level effect. |
random_slope |
If TRUE, includes a random slope effect. |
fixed |
A formula that overwrites the automatically created fixed part of the regression model that defaults to the standard piecewise regression model. The parameter phase followed by the phase name (e.g., phaseB) indicates the level effect of the corresponding phase. The parameter 'inter' followed by the phase name (e.g., interB) adresses the slope effect based on the method provide in the model argument (e.g., "B&L-B"). The formula can be changed for example to include further L1 or L2 variables into the regression model. |
random |
A formula that overwrites the automatically created random part of the regression model. |
update_fixed |
An easier way to change the fixed model part (e.g., |
... |
Further arguments passed to the |
x |
An object returned by |
digits |
The minimum number of significant digits to be use. If set to "auto" (default), values are predefined. |
object |
An scdf or an object exported from a scan function. |
caption |
Character string with table caption. If left NA (default) a caption will be created based on the exported object. |
footnote |
Character string with table footnote. If left NA (default) a footnote will be created based on the exported object. |
filename |
String containing the file name. If a filename is given the output will be written to that file. |
round |
Integer passed to the digits argument used to round values. |
nice |
If set TRUE (default) output values are rounded and optimized for publication tables. |
The function uses the MCMCglmm::MCMCglmm() function to fit the model. The
default model includes fixed trend, level, and slope effects as well as a
random intercept for each single-case. The fixed part of the model can be
changed by providing a custom formula to the fixed argument or by using the
update_fixed argument. The random part of the model can be changed by
providing a custom formula to the random argument or by setting the
random_trend, random_level, or random_slope arguments to TRUE.
An object of class sc_bplm with element:
model - List containing information about the applied model.
N - Number of single-cases.
formula - A list containing the fixed and the random formulas of the hplm model.
mcmglmm - Object of class MCMglmm.
contrast - List with contrast definitions.
print(sc_bplm): Print results
export(sc_bplm): Export results as html table (see export())
Juergen Wilbert
Other regression functions:
fetch(),
hplm(),
mplm(),
plm(),
print.sc_ac(),
print.sc_bctau(),
trend()
# plm regression
bplm(example_A24)
# Multilevel plm regression with random intercept
bplm(exampleAB_50, nitt = 5000)
# Adding a random slope
bplm(exampleAB_50, random_level = TRUE, nitt = 5000)
# Custom fixed formula
bplm(exampleAB_50, update_fixed = values ~ -1 + mt + phaseB +
interB, nitt = 5000)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.