bplm: Bayesian Piecewise Linear Model

View source: R/bplm.R

bplmR Documentation

Bayesian Piecewise Linear Model

Description

Computes a bayesian (hierarchical) piecewise linear model based on a Markov chain Monte Carlo sampler.

Usage

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,
  kable_styling_options = list(),
  kable_options = list(),
  round = 2,
  nice = TRUE,
  ...
)

Arguments

data

A single-case data frame. See scdf() to learn about this format.

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 model = "W". Possible values are: "B&L-B", "H-M", "W", and deprecated "JW".

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., . ~ . + newvariable).

...

Further arguments passed to the mcmcglmm function.

x

An object returned by bplm()

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.

kable_styling_options

list with arguments passed to the kable_styling function.

kable_options

list with arguments passed to the kable function.

round

Integer passed to the digits argument internally used to round values.

nice

If set TRUE (default) output values are rounded and optimized for publication tables.

Value

An object of class sc_bplm.

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.

Functions

  • print(sc_bplm): Print results

  • export(sc_bplm): Export results as html table (see export())

Author(s)

Juergen Wilbert

See Also

Other regression functions: autocorr(), corrected_tau(), hplm(), mplm(), plm(), trend()

Examples

bplm(exampleAB_50)
bplm(exampleAB_50, random_level = TRUE)

jazznbass/scan documentation built on Feb. 28, 2025, 3:39 a.m.