plm | R Documentation |
The plm
function computes a piecewise regression model (see Huitema &
McKean, 2000).
plm(
data,
dvar,
pvar,
mvar,
AR = 0,
model = c("W", "H-M", "B&L-B", "JW"),
family = "gaussian",
trend = TRUE,
level = TRUE,
slope = TRUE,
contrast = c("first", "preceding"),
contrast_level = c(NA, "first", "preceding"),
contrast_slope = c(NA, "first", "preceding"),
formula = NULL,
update = NULL,
na.action = na.omit,
r_squared = TRUE,
var_trials = NULL,
dvar_percentage = FALSE,
...
)
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. |
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 |
model |
Model used for calculating the dummy parameters (see Huitema &
McKean, 2000). Default is |
family |
Set the distribution family. Defaults to a gaussian
distribution. See the |
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. |
contrast |
Sets contrast_level and contrast_slope. Either "first", "preceding" or a contrast matrix. |
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. |
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., |
na.action |
Defines how to deal with missing values. |
r_squared |
Logical. If TRUE, delta r_squares will be calculated for each predictor. |
var_trials |
Name of the variable containing the number of trials (only for binomial regressions). If a single integer is provided this is considered to be a the constant number of trials across all measurements. |
dvar_percentage |
Only for binomial distribution. If set TRUE, the
dependent variable is assumed to represent proportions |
... |
Further arguments passed to the glm function. |
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 |
F.test |
F-test values of modelfit. |
r.squares |
Explained variance R squared for each model parameter. |
ar |
Autoregression lag from function call (see |
family |
Distribution family from function call
(see |
full.model |
Full regression model list from the gls or glm function. |
Juergen Wilbert
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.
Other regression functions:
autocorr()
,
corrected_tau()
,
hplm()
,
mplm()
,
trend()
## Compute a piecewise regression model for a random single-case
set.seed(123)
AB <- design(
phase_design = list(A = 10, B = 20),
level = list(A = 0, B = 1), slope = list(A = 0, B = 0.05),
trend = 0.05
)
dat <- random_scdf(design = AB)
plm(dat, AR = 3)
## Another example with a more complex design
A1B1A2B2 <- design(
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, A2 = 0, B2 = 0.0),
trend = 0.0)
dat <- random_scdf(design = A1B1A2B2, seed = 123)
plm(dat, contrast = "preceding")
## no slope effects were found. Therefore, you might want to the drop slope
## estimation:
plm(dat, slope = FALSE, contrast = "preceding")
## and now drop the trend estimation as well
plm(dat, slope = FALSE, trend = FALSE, contrast = "preceding")
## A poisson regression
example_A24 %>%
plm(family = "poisson")
## A binomial regression (frequencies as dependent variable)
plm(exampleAB_score$Christiano, family = "binomial", var_trials = "trials")
## A binomial regression (percentage as dependent variable)
exampleAB_score$Christiano %>%
transform(percentage = values/trials) %>%
set_dvar("percentage") %>%
plm(family = "binomial", var_trials = "trials", dvar_percentage = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.