# NOT RUN {
## 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")
# }
Run the code above in your browser using DataLab