Description Usage Arguments Value Author(s) References See Also Examples
View source: R/piecewiseRegr.R
This function conducts a piecewise regression analysis and shows a plot illustrating the results. The function enables easy customization of the main plot elements and easy saving of the plot with anti-aliasing.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | piecewiseRegr(data,
timeVar = 1,
yVar = 2,
phaseVar = NULL,
baselineMeasurements = NULL,
robust = FALSE,
digits = 2,
colors = list(pre = viridis(4)[1],
post = viridis(4)[4],
diff = viridis(4)[3],
intervention = viridis(4)[2],
points = "black"),
theme = theme_minimal(),
pointSize = 2,
pointAlpha = 1,
lineSize = 1,
yRange=NULL,
yBreaks = NULL,
showPlot = TRUE,
plotLabs = NULL,
outputFile = NULL,
outputWidth = 16,
outputHeight = 16,
ggsaveParams = list(units = "cm",
dpi = 300,
type = "cairo"))
|
data |
The dataframe containing the variables for the analysis. |
timeVar |
The name of the variable containing the measurement moments (or an index of measurement moments). An index can also be specified, and assumed to be 1 if omitted. |
yVar |
The name of the dependent variable. An index can also be specified, and assumed to be 2 if omitted. |
phaseVar |
The variable containing the phase of each measurement. Note that this normally should only have two possible values. |
baselineMeasurements |
If no phaseVar is specified, |
robust |
Whether to use normal or robust linear regression. |
digits |
The number of digits to show in the results. |
colors |
The colors to use for the different plot elements. |
theme |
The theme to use in the plot. |
pointSize,lineSize |
The sizes of points and lines in the plot. |
yRange |
This can be used to manually specify the possible values that the dependent variable can take. If not provided, the observed range of the dependent variable values is used instead. |
yBreaks |
If |
pointAlpha |
The alpha channel (transparency, or rather, 'opaqueness') of the points. |
showPlot |
Whether to show the plot or not. |
plotLabs |
A list with arguments to the |
outputFile |
If not |
outputWidth, outputHeight |
The dimensions of the plot when saving it (in units specified in |
ggsaveParams |
The parameters to use when saving the plot, passed on to |
Mainly, this function prints its results, but it also returns them in an object containing three lists:
input |
The arguments specified when calling the function |
intermediate |
Intermediat objects and values |
output |
The results such as the plot. |
Peter Verboon & Gjalt-Jorn Peters (both at the Open University of the Netherlands)
Maintainer: Gjalt-Jorn Peters <gjalt-jorn@userfriendlyscience.com>
Verboon, P. & Peters, G.-J. Y. (2018) Applying the generalised logistic model in single case designs: modelling treatment-induced shifts. PsyArXiv https://doi.org/10.17605/osf.io/ad5eh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ### Load dataset
data(Singh);
### Extract Jason
dat <- Singh[Singh$tier==1, ];
### Conduct piecewise regression analysis
piecewiseRegr(dat,
timeVar='time',
yVar='score_physical',
phaseVar='phase');
### Pretend treatment started between measurements
### 5 and 6
piecewiseRegr(dat,
timeVar='time',
yVar='score_physical',
baselineMeasurements=5);
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.