cosinor() fits a regression model of a time variable to a
continuous outcome use trigonometric features. This approaches uses the
linearization of the parameters to assess their statistics and
distribution.
Usage
cosinor(t, ...)
# Default S3 method
cosinor(t, ...)
# S3 method for class 'data.frame'
cosinor(t, y, tau, population = NULL, ...)
# S3 method for class 'matrix'
cosinor(t, y, tau, population = NULL, ...)
# S3 method for class 'formula'
cosinor(formula, data, tau, population = NULL, ...)
# S3 method for class 'recipe'
cosinor(t, data, tau, population = NULL, ...)Arguments
- t
Represents the ordered time indices that provide the positions for the cosine wave. Depending on the context:
A
data frameof a time-based predictor/index.A
matrixof time-based predictor/index.A
recipespecifying a set of preprocessing steps created fromrecipes::recipe().
- ...
Not currently used, but required for extensibility.
- y
When t is a
data frameormatrix, y is the outcome specified as:A
data framewith 1 numeric column.A
matrixwith 1 numeric column.A numeric
vector.
- tau
A vector that determines the periodicity of the time index. The number of elements in the vector determine the number of components (e.g. single versus multiple cosinor).
A
vectorwith a single element = single-component cosinor, e.g. period = c(24)A
vectorwith multiple elements = multiple-component cosinor, e.g. period = c(24, 12)
- population
Represents the population to be analyzed with a population-mean cosinor. Defaults to NULL, assuming individual cosinors are being generated. When a
recipeorformulais used, population is specified as:A
charactername of the column contained in data that contains identifiers for each subject. Every row will have a subject name which should be duplicated for each time index given.
When a
data frameormatrixis used, population is specified as:A
vectorof the same length as t, with values representing each subject at the correct indices.
- formula
A formula specifying the outcome terms on the left-hand side, and the predictor terms on the right-hand side.
- data
When a
recipeorformulais used, data is specified as:A
data framecontaining both the predictors and the outcome.
See also
Other cosinor:
augment.cosinor(),
ggcosinor()
Examples
# Data setup
data("twins")
# Formula interface
model <- cosinor(rDYX ~ hour, twins, tau = 24)