acc_loess: Smoothes and plots adjusted longitudinal measurements

View source: R/acc_loess.R

acc_loessR Documentation

Smoothes and plots adjusted longitudinal measurements


The following R implementation executes calculations for quality indicator Unexpected distribution wrt location (link). Local regression (LOESS) is a versatile statistical method to explore an averaged course of time series measurements (Cleveland, Devlin, and Grosse 1988). In context of epidemiological data, repeated measurements using the same measurement device or by the same examiner can be considered a time series. LOESS allows to explore changes in these measurements over time.


  co_vars = NULL,
  label_col = NULL,
  resolution = 180,
  se_line = list(color = "red", linetype = 2),
  plot_format = "AUTO"



variable the name of the continuous measurement variable


variable the name of the observer, device or reader variable


variable a variable identifying the variable with the time of measurement


variable list a vector of covariables, e.g. age and sex for adjustment. Can be NULL (default) for no adjustment.


integer from=0. optional argument if group_vars are used. This argument specifies the minimum number of observations that is required to include a subgroup (level) of the group variable named by group_vars in the analysis. Subgroups with less observations are excluded. The default is 30.


variable attribute the name of the column in the metadata with labels of variables


data.frame the data frame that contains the measurements


data.frame the data frame that contains metadata attributes of study data


numeric how many timepoints have a standard error estimation


list standard error estimator line style, as arguments passed to ggplot2::geom_line()


logical mark times with data values (caution, there may be many marks)


enum AUTO | COMBINED | FACETS | BOTH. Return the LOESS plot as a combined plot or as facets plots one per group. BOTH will return both plot variants, AUTO will decide based on the number of observers.


If plot_data_time is not set, it will be selected based on the number of data points per group: If more than 4000 points would be plotted for at least one group, the > 4000 marks will not be plotted.


The application of LOESS usually requires model fitting, i.e. the smoothness of a model is subject to a smoothing parameter (span). Particularly in the presence of interval-based missing data (USR_181), high variability of measurements combined with a low number of observations in one level of the group_vars the fit to the data may be distorted. Since our approach handles data without knowledge of such underlying characteristics, finding the best fit is complicated if computational costs should be minimal. The default of LOESS in R uses a span 0.75 which provides in most cases reasonable fits. The function above increases the fit to the data automatically if the minimum of observations in one level of the group_vars is higher than n=30.


a list with:

  • SummaryPlotList: list with two plots:

    • Loess_fits_facets: ggplot2 LOESS plot provides panels for each subject/object. The plot contains LOESS-smoothed curves for each level of the group_vars. The red dashed lines represent the confidence interval of a LOESS curve for the whole data.

    • Loess_fits_combined: ggplot2 LOESS plot combines all curves into one panel and is obtained by myloess$Loess_fits_combined. Given a low number of levels in the group_vars this plot eases comparisons. However, if number increases this plot may be too crowded and unclear.

See Also

Online Documentation

dataquieR documentation built on July 26, 2023, 6:10 p.m.