Create visualization of a CosinorM or CosinorM.KDE fit using ggplot2. The plot shows the parametric cosinor fit over a fine time grid, optional pointwise confidence bands, observed data points, MESOR line, acrophase verticals, amplitude annotation segments, and labelled parameter values when requested.
Usage
ggCosinorM(
object,
labels = TRUE,
ci = TRUE,
ci_level = 0.95,
n = 400,
point_size = 0.5,
title_extra = NULL,
legend.position = "right",
...
)Arguments
- object
A fitted model of class
CosinorMorCosinorM.KDE.- labels
Logical; Default: TRUE, which places repelled labels on the plot with MESOR, amplitude(s), and acrophase(s).
- ci
Logical; Default: TRUE, which computes and draws pointwise parametric confidence bands for the fitted cosinor curve using the model covariance.
- ci_level
Numeric scaler. The range of the confidence interval, expressed in numeric value between 0 and 1. Default: 0.95
- n
Integer scaler. Number of points on the fine prediction grid used to draw the fitted cosinor and confidence ribbon. Default: 400
- point_size
Numeric scaler. Plotting size for observed points. Default: 0.5
- title_extra
Optional character string appended to the plot title for extra context.
- legend.position
Position of the legend on the plot; default is "right". Other options include "top", "bottom", "left", or a numeric vector of length two specifying x and y coordinates.
- ...
Additional arguments (currently ignored) kept for future update.
Examples
if (FALSE) { # \dontrun{
# Import data
data (FlyEast)
BdfList <-
BriefSum (
df = FlyEast,
SR = 1 / 60,
Start = "2017-10-24 13:45:00"
)
# Let's extract actigraphy data from a single day
df <- BdfList$df
df <- subset (df, df$Date == "2017-10-28")
fit <- CosinorM (
time = df$Time,
activity = df$Activity,
tau = 24,
method = "OLS"
)
p <- ggCosinorM (
object = fit,
labels = TRUE,
ci = TRUE,
ci_level = 0.95,
title_extra = "2017-10-24"
)
print (p)
} # }
