plm: Piecewise linear model / piecewise regression

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/plm.R

Description

The plm function computes a piecewise regression model (see Huitema & McKean, 2000).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
plm(
  data,
  dvar,
  pvar,
  mvar,
  AR = 0,
  model = "B&L-B",
  family = "gaussian",
  trend = TRUE,
  level = TRUE,
  slope = TRUE,
  formula = NULL,
  update = NULL,
  na.action = na.omit,
  ...
)

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.

AR

Maximal lag of autoregression. Modeled based on the Autoregressive-Moving Average (ARMA) function. When AR is set, the family argument must be set to family = "gaussian".

model

Model used for calculating the slope parameter (see Huitema & McKean, 2000). Default is model = "B&L-B". Possible values are: "B&L-B", "H-M", "Mohr#1", "Mohr#2", "JW", "JW2", and "Manly".

family

Set the distributioin family. Defaults to a gaussian distribution. See the family function for more details.

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.

formula

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 variables into the regression model.

update

An easier way to change the regression formula (e.g., . ~ . + newvariable).

na.action

Defines how to deal with missing values

...

Further arguments passed to the glm function.

Value

formula

plm formula. Uselful if you want to use the update or formula argument and you don't know the names of the parameters.

model

Character string from function call (see Arguments above).

F.test

F-test values of modelfit.

r.squares

Explained variance R squared for each model parameter.

ar

Autoregression lag from function call (see Arguments above).

family

Distribution family from function call (see Arguments above).

full.model

Full regression model list from the gls or glm function.

Author(s)

Juergen Wilbert

References

Beretvas, S., & Chung, H. (2008). An evaluation of modified R2-change effect size indices for single-subject experimental designs. Evidence-Based Communication Assessment and Intervention, 2, 120-128.

Huitema, B. E., & McKean, J. W. (2000). Design specification issues in time-series intervention models. Educational and Psychological Measurement, 60, 38-58.

See Also

Other regression functions: corrected_tau(), hplm(), mplm()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## Compute a piecewise regression model for a random single-case
set.seed(123)
AB <- design_rSC(
  phase.design = list(A = 10, B = 20), 
  level = list(A = 0, B = 1), slope = list(A = 0, B = 0.05), 
  trend = list(0.05)
)
dat <- rSC(design = AB)
plm(dat, AR = 3)

## Another example with a more complex design
A1B1A2B2 <- design_rSC(
  phase.design = list(A1 = 15, B1 = 20, A2 = 15, B2 = 20), 
  level = list(A1 = 0, B1 = 1, A2 = -1, B2 = 1),
  slope = list(A1 = 0, B1 = 0.0, A1 = 0, B2 = 0.0),
  trend = list(0.0))
dat <- rSC(design = A1B1A2B2, seed = 123)
plm(dat, model = "JW")

## no slope effects were found. Therefore you might want to drop slope estimation:
plm(dat, slope = FALSE, model = "JW")

## and now drop the trend estimation as well
plm(dat, slope = FALSE, trend = FALSE, model = "JW")

scan documentation built on Feb. 22, 2021, 5:08 p.m.