userfriendlyscience (version 0.7.2)

therapyMonitor: therapyMonitor & therapyMonitor.multi


therapyMonitor & therapyMonitor.multi are useful for simple n-of-1 designs, and were written to make it easy for therapists or other practitioners to get some insight into the effects of their treatments.


therapyMonitor(dat = NULL, design="AB", statistic="|A-B|",
               conditionColumn = NULL, variableColumn = NULL,
               timeColumn = NULL, conditionMoment = NULL,
               limit=NULL, lines=NULL, ylab=NULL, xlab=NULL,
               outputFile = NULL, outputFormats = c('svg', 'png'),
               plotTitle = "therapyMonitor results",
               plotWidth=25, plotHeight=15)
therapyMonitor.multi(dat = NULL,
                     variableColumn = NULL, conditionColumn = NULL,
                     conditionMoment = NULL, minLevels = 5,
                     outputFiles = FALSE, outputFilePath = getwd(),
                     outputFormats = c('svg', 'png'), silent=FALSE,



A dataframe containing the variables to analyse. If not dataframe is specified, get getData function is used to present a dialog to the user.


The design to use; see pvalue.systematic in the SCRT-package for more information. Note that currently, this function always assumes an "AB" design; changing this only changes the way pvalue.systematic is called.


The statistic to use; see pvalue.systematic in the SCRT-package for more information. Note that currently, this function always assumes the "|A-B|" statistic; changing this only changes the way pvalue.systematic is called.


The name of the variable containing, for each measurement, the condition, or the phase of the treatment. This variable should normally only have two levels (e.g. 'A' and 'B'), indicating when the treatment changed from condition 'A' to condition 'B'.


For therapyMonitor, this must be a single value: the name of the variable to analyse as dependent variable. For therapyMonitor.multi, this can be a vector, in which case all the specified variables are analysed sequentially. In any case, the variable(s) specified here must have the 'interval' measurement level (i.e. be roughly continuous). For therapyMonitor.multi, if this argument is empty, all variables are used, provided they have at least minLevels levels.


The variable containing the time (datetime) of each measurement moment. If not specified in R's POSIXct format, the function tries to guess whether SPSS, SAS, or Stata timestamps were specified, and tries to convert. If the timeColumn isn't specified, the function will assume that all measurements were equidistant, and they'll simply be assigned consecutive numbers als measurement moments.


The conditionMoment argument provides an alternative method of specifying when the condition changed; this can be the number of the first measurement in the new (second) condition/phase. For example, if the treatment started after the 6th measurement, this can be specified by passing 'conditionMoment=7'.


The minimum number of consecutive measurements that has to be available within one condition/phase to enable the analysis (see pvalue.systematic).


Which lines in the dat dataframe to use.

ylab, xlab

Labels to use when creating the plots.


If not NULL, the filename to write the plot to. Note that this filename should not include the extension - this is appended based on the outputFormats argument.


Which format to use for the plot or plots to export.


The title for the plot.

plotWidth, plotHeight

The size of the plot (in centimeters).


The minimum number of levels that a variable in the datafile has to have before it's included in the analyses.


Whether to export the plots and regular output to files.


If outputFiles is TRUE, the path where to store the output files.


Whether to suppress messages about progress etc.


Additional arguments to therapyMonitor.multi are passed on to therapyMonitor.


For therapyMonitor, an object with the input and several output variables, as well as a plot. For therapyMonitor.multi, an object containing several therapyMonitor objects, as well as collated output.


This function started as a wrapper to the pvalue.systematic function in the SCRT-package, but it now also does some extra stuff.


### Explore and plot the weight of a chick in the ChickWeight dataset
therapyMonitor(ChickWeight, variableColumn='weight',
               conditionMoment=6, lines=1:12);
# }