Title: | Extended Tools for Cosinor Analysis of Rhythms |
---|---|
Description: | Statistical procedures for calculating population–mean cosinor, non–stationary cosinor, estimation of best–fitting period, tests of population rhythm differences and more. See Cornélissen, G. (2014). <doi:10.1186/1742-4682-11-16>. |
Authors: | Augustin Mutak <[email protected]> |
Maintainer: | Augustin Mutak <[email protected]> |
License: | GPL-3 |
Version: | 0.2.0 |
Built: | 2025-02-11 04:27:34 UTC |
Source: | https://github.com/amutak/cosinor2 |
Corrects the value of the acrophase parameter of the cosinor model, placing it in the appropriate quadrant.
correct.acrophase(x)
correct.acrophase(x)
x |
An object of the |
The acrophase parameter of a cosinor model is found by solving an equation with inverse tangent of an expression which contains linearized cosinor parameters. However, multiple numeric entities may result in a same value of tangent and just calculating the inverse tangent may result with the wrong value of the acrophase. This function corrects the acrophase from the cosinor.lm
object according to the procedure from Bingham et al. (1982).
More specifically, the acrophase is calculated as:
where values of and
depend on the signs of
and
and can be derived from the following table:
sign |
sign |
K | g |
+ | + | 0 | -1 |
+ | - | -2 |
1 |
- | + | - |
1 |
- | - | - |
-1 |
Bingham, C., Arbogast, B., Guillaume Cornélissen, G., Lee, J.K. & Halberg, F. (1982). Inferential Statistical Methods for Estimating and Comparing Cosinor Parameters. Chronobiologia, 9(4), 397-439.
fit.temperature<-cosinor.lm(Temperature~time(Time), period = 24, data = temperature_zg) correct.acrophase(fit.temperature)
fit.temperature<-cosinor.lm(Temperature~time(Time), period = 24, data = temperature_zg) correct.acrophase(fit.temperature)
Performs the rhythm detection test, a global test for the significance of the estimated model for single cosinor and population-mean cosinor.
cosinor.detect(x)
cosinor.detect(x)
x |
An object of the |
The rhythm detection test, also called the zero-amplitude test, tests the overall significance of the cosinor model. The test is actually an F-ratio and is calculated as following (according to the procedure described in Cornélissen, 2014):
with and
, where
is the
th estimated value,
is the
th observed value,
is the arithmetic mean of observed values and
is the number of timepoints.
For the population-mean cosinor model, the test is calculated according to the procedure described in Bingham et al. (1982) as follows:
with and
, where
is the number of subjects in the population,
and
are standard deviations of population
and
coefficients and
is the covariance of population
and
coefficients.
Cornélissen, G. (2014). Cosinor-Based Rhythmometry. Theoretical Biology and Medical Modeling, 11, Article 16.
Bingham, C., Arbogast, B., Guillaume Cornélissen, G., Lee, J.K. & Halberg, F. (1982). Inferential Statistical Methods for Estimating and Comparing Cosinor Parameters. Chronobiologia, 9(4), 397-439.
fit.temperature<-cosinor.lm(Temperature~time(Time), period = 24, data = temperature_zg) cosinor.detect(fit.temperature) fit.november<-population.cosinor.lm(data = PANAS_november, time = PANAS_time, period = 7) cosinor.detect(fit.november)
fit.temperature<-cosinor.lm(Temperature~time(Time), period = 24, data = temperature_zg) cosinor.detect(fit.temperature) fit.november<-population.cosinor.lm(data = PANAS_november, time = PANAS_time, period = 7) cosinor.detect(fit.november)
Runs the tests that compare MESORs, amplitudes and acrophases of two different populations.
cosinor.poptests(pop1, pop2)
cosinor.poptests(pop1, pop2)
pop1 |
An object of the |
pop2 |
An object of the |
Bingham et al. (1982) describe tests for comparing population MESORs, amplitudes and acrophases. These tests are esentially F-ratios with and
, where
is the number of populations and
is the total number of subjects. The tests for MESOR, amplitude and acrophase differences respectively are calculated as follows:
where ,
and
are weighted averages of parameters across populations calculated as:
is derived from the following expression:
where lies between
and
if the denomanator is positive or between
and
if the denominator is negative,
is the number of subjects in the
th population,
,
and
are the cosinor parameters of the
th population and
,
and
are the estimates of pooled standard deviations (and covariance) calculated as following:
where ,
and
are the standard devations and covariance of
and
parameters in the
th population.
These tests should only be performed on independent samples. If the acrophases of two populations are significantly different, the results of the amplitude difference test are not reliable and should not be interpreted. While it's possible to perform tests which compare more than two populations, this function can only compare two populations.
Bingham, C., Arbogast, B., Guillaume Cornélissen, G., Lee, J.K. & Halberg, F. (1982). Inferential Statistical Methods for Estimating and Comparing Cosinor Parameters. Chronobiologia, 9(4), 397-439.
fit.extraverts<-population.cosinor.lm(data = PA_extraverts, time = PA_time, period = 24) fit.introverts<-population.cosinor.lm(data = PA_introverts, time = PA_time, period = 24) cosinor.poptests(pop1 = fit.extraverts, pop2 = fit.introverts)
fit.extraverts<-population.cosinor.lm(data = PA_extraverts, time = PA_time, period = 24) fit.introverts<-population.cosinor.lm(data = PA_introverts, time = PA_time, period = 24) cosinor.poptests(pop1 = fit.extraverts, pop2 = fit.introverts)
Calculates Percent Rhythm, the measure of the relative strength of a rhythm.
cosinor.PR(x)
cosinor.PR(x)
x |
An object of the |
Percent Rhythm is the coefficient of determination obtained by squaring the correlation between observed and estimated values.
fit.temperature<-cosinor.lm(Temperature~time(Time), period = 24, data = temperature_zg) cosinor.PR(fit.temperature) fit.november<-population.cosinor.lm(data = PANAS_november, time = PANAS_time, period = 7) cosinor.PR(fit.november)
fit.temperature<-cosinor.lm(Temperature~time(Time), period = 24, data = temperature_zg) cosinor.PR(fit.temperature) fit.november<-population.cosinor.lm(data = PANAS_november, time = PANAS_time, period = 7) cosinor.PR(fit.november)
A dataset containing the responses of 24 subjects on the Positive Affect scale of the shortened version of the PANAS questionnaire (Watson, Clark & Tellegen, 1988) in January 2017.
PA_extraverts
PA_extraverts
A data frame with 24 rows and 6 variables:
Responses of subjects at 6 measurement points (hours).
Measurements were taken at 10 AM, 12 PM, 2 PM, 4 PM, 6 PM and 8 PM 30 minutes in the period of January 16 - 22, 2017. The data contained in this dataset has been averaged for each hour across 7 days of measurement.
Mutak, A., Pavlović, M. & Zibar, K. (2017, May). Postoje li razlike između introverata i ekstraverata u cirkadijurnim ritmovima raspoloženja? [Are There Differences Between Introverts and Extraverts in Circadian Mood Rhythms?]. Study presented at the 3rd Regionalni susret studenata psihologije - SPIRI [Regional Meeting of Psychology Students - SPIRI] conference, Rijeka, Croatia.
Watson, D., Clark, L. A. & Tellegen, A. (1988). Development and Validation of Brief Measures of Positive and Negative Affect: The PANAS Scales. Journal of Personality and Social Psychology, 54(6), 1063-1070.
A dataset containing the responses of 29 subjects on the Positive Affect scale of the shortened version of the PANAS questionnaire (Watson, Clark & Tellegen, 1988) in January 2017.
PA_introverts
PA_introverts
A data frame with 29 rows and 6 variables:
Responses of subjects at 6 measurement points (hours).
Measurements were taken at 10 AM, 12 PM, 2 PM, 4 PM, 6 PM and 8 PM 30 minutes in the period of January 16 - 22, 2017. The data contained in this dataset has been averaged for each hour across 7 days of measurement.
Mutak, A., Pavlović, M. & Zibar, K. (2017, May). Postoje li razlike između introverata i ekstraverata u cirkadijurnim ritmovima raspoloženja? [Are There Differences Between Introverts and Extraverts in Circadian Mood Rhythms?]. Study presented at the 3rd Regionalni susret studenata psihologije - SPIRI [Regional Meeting of Psychology Students - SPIRI] conference, Rijeka, Croatia.
Watson, D., Clark, L. A. & Tellegen, A. (1988). Development and Validation of Brief Measures of Positive and Negative Affect: The PANAS Scales. Journal of Personality and Social Psychology, 54(6), 1063-1070.
A dataset containing the measurement times (hours) of self reported positive affect contained in the data frames PA_extravers
and PA_introverts
.
PA_time
PA_time
A numeric vector of length 6.
Mutak, A., Pavlović, M. & Zibar, K. (2017, May). Postoje li razlike između introverata i ekstraverata u cirkadijurnim ritmovima raspoloženja? [Are There Differences Between Introverts and Extraverts in Circadian Mood Rhythms?]. Study presented at the 3rd Regionalni susret studenata psihologije - SPIRI [Regional Meeting of Psychology Students - SPIRI] conference, Rijeka, Croatia.
A dataset containing the responses of 19 subjects on the shortened version of the PANAS questionnaire (Watson, Clark & Tellegen, 1988) in November 2015.
PANAS_november
PANAS_november
A data frame with 19 rows and 30 variables:
Responses of subjects at 30 measurement points (days).
Measurements were taken every day after 8 PM.
The data contained in this dataset has been reduced compared to the original data that included more subjects. This dataset contains only the subjects that have responded to the PANAS questionnaire on more than 85% of the timepoints in both of the research cycles (July and November).
Mutak, A. i Vukasović Hlupić, T. (2017). Exogeneity of the Circaseptan Mood Rhythm and Its Relation to the Working Week. Review of Psychology, 24 (1-2), 15-28.
Watson, D., Clark, L. A. & Tellegen, A. (1988). Development and Validation of Brief Measures of Positive and Negative Affect: The PANAS Scales. Journal of Personality and Social Psychology, 54(6), 1063-1070.
A dataset containing the measurement times (dates) of self reported mood contained in the data frame PANAS_november
PANAS_time
PANAS_time
A numeric vector of length 30.
Mutak, A. i Vukasović Hlupić, T. (2017). Exogeneity of the Circaseptan Mood Rhythm and Its Relation to the Working Week. Review of Psychology, 24 (1-2), 15-28.
Estimates the best-fitting period using iterative cosinor procedure.
periodogram(data, time, periods = time, na.action = na.omit, alpha = 0.05)
periodogram(data, time, periods = time, na.action = na.omit, alpha = 0.05)
data |
A data frame containing responses of subjects collected over time, with subjects in the rows and timepoints in the columns. |
time |
A vector containing the times at which the data was collected. If this vector includes midnight, it should be coded as 24 instead of 0. |
periods |
A vector containing periods that are to be included in the periodogram. Defaults to the same periods as provided in the vector |
na.action |
Action to be performed on missing values. Defaults to |
alpha |
Significance level for determining if a rhythm with a given period is significant or not. Defaults to .05. |
Iterative cosinor procedure is performed as described in Klemfuss & Clopton (1993). Cosinor is performed iteratively with the period () increased by 1 in each iteration. Percent Rhythm is calculated in each iteration, which allows for an estimation of the best fitting period. A periodogram can be plotted, which shows Percent Rhythm (coefficient of determination) for each period. On the plot, periods with significant rhythm are shown as a point and periods with insignificant rhythm are shown as a cross.
The range of periods included in iterations starts from 3 (sinusoidality of the curve is not achieved for < 3) and ends with the number of timepoints in the data.
Klemfuss, H. & Clopton, P. L. (1993). Seeking Tau: A Comparison of Six Methods. Journal of Interdisciplinary Cycle Research, 24(1), 1-16.
periodogram(data = PANAS_november, time = PANAS_time) periodogram(data = t(data.frame(temperature_zg$Temperature)), time = temperature_zg$Time)
periodogram(data = PANAS_november, time = PANAS_time) periodogram(data = t(data.frame(temperature_zg$Temperature)), time = temperature_zg$Time)
Calculates the population-mean cosinor.
population.cosinor.lm(data, time, period, na.action = na.omit, alpha = 0.05, plot = T)
population.cosinor.lm(data, time, period, na.action = na.omit, alpha = 0.05, plot = T)
data |
A data frame containing responses of subjects collected over time, with subjects in the rows and timepoints in the columns. |
time |
A vector containing the times at which the data was collected. |
period |
Duration of one cycle of rhythm. |
na.action |
Action to be performed on missing values. Defaults to |
alpha |
Significance level for calculating population cosinor parameters confidence intervals. Defaults to .05 (confidence intervals are 5% risk intervals). |
plot |
Logical, display plot after calculation? Defaults to |
According to the procedure described in Cornélissen (2014), to calculate population-mean cosinor, single cosinors are first performed on each subject and linearized parameters are averaged, which allows for calculation of delinearized parameters. After such a procedure is completed, confidence intervals of population-mean cosinor parameters can be calculated as described in Bingham et al. (1982) using the following formulae:
where ,
and
are elements of the sampling scheme matrix, calculated as follows:
where ,
,
,
and
are population-mean cosinor parameters,
,
and
are the standard deviations of the single cosinor parameters,
is the covariance of the single cosinor
and
coefficients,
is the number of subjects in a population and
is the two-tailed inverse of the t-distribution with
level of significance and
degrees of freedom.
Object of the population.cosinor.lm
class containing the following objects:
single.cos |
A list of objects containing all performed single cosinors. |
pop.mat |
A data frame containing the cosinor parameters of each subject in the population. |
coefficients |
Delinearized population-mean cosinor coefficients. |
emp.mean |
Empirical mean of the data across all timepoints. |
fitted.values |
Estimated values of the rhythm caclculated using the cosinor model. |
residuals |
The difference between empirical mean and the fitted values. |
conf.int |
Values of upper and lower limits of confidence intervals of delinearized cosinor parameters. |
If the confidence interval of the population amplitude includes zero, confidence interval of the acrophase cannot be calculated reliably. If this case occurs while using this function, the user will be warned and acrophase confidence interval limits will be set to NA.
Cornélissen, G. (2014). Cosinor-Based Rhythmometry. Theoretical Biology and Medical Modeling, 11, Article 16.
Bingham, C., Arbogast, B., Guillaume Cornélissen, G., Lee, J.K. & Halberg, F. (1982). Inferential Statistical Methods for Estimating and Comparing Cosinor Parameters. Chronobiologia, 9(4), 397-439.
population.cosinor.lm(data = PANAS_november, time = PANAS_time, period = 7, na.action = "na.exclude")
population.cosinor.lm(data = PANAS_november, time = PANAS_time, period = 7, na.action = "na.exclude")
Performs serial section analysis of rhythmic data and fits non-stationary cosinor models.
ssections(data, time, period, interval, increment, na.action = na.omit, alpha = 0.05)
ssections(data, time, period, interval, increment, na.action = na.omit, alpha = 0.05)
data |
A data frame containing responses of subjects collected over time, with subjects in the rows and timepoints in the columns. |
time |
A vector containing the times at which the data was collected. |
period |
Duration of one cycle of rhythm. |
interval |
Length of an interval (number of timepoints) on which cosinor analyses will be ran. |
increment |
A number indicating for how much timepoints should the interval be displaced throughout the data. Note that the value of the increment cannot be higher than the value of the interval. |
na.action |
Action to be performed on missing values. Defaults to |
alpha |
Significance level for calculating population cosinor parameters confidence intervals. Defaults to .05 (confidence intervals are 5% risk intervals). |
Cornélissen (2014) describes procedures for rhythmometric analysis of non-stationary data. First, an interval of an user-specified length () is chosen and usual cosinor analysis (i.e. single cosinor or population-mean cosinor) is performed on the interval. The interval is then displaced throughout the data by an user-specified increment (
) and cosinor analysis is then performed on the new interval. Intervals can be overlapping (
<I) or non-overlapping (
=I). A rhythm detection test is also calculated in each interval. After values of cosinor parameters have been obtained for each interval, they and their confidence intervals can be plotted, along with the p-values from the rhythm detection test.
Object of the Serial sections
class containing the following objects:
coefficients |
Cosinor coefficients in each of the intervals. |
emp.mean |
Empirical mean of the data across all timepoints. |
p-values |
p-values from the rhythm detection test in each interval. |
cosinors |
A list containing all cosinor objects calculated in each interval. |
plots |
Stacked plots showing the empirical data, cosinor parameters and their confidence intervals, p-values of the rhythm detection test and number of measurements across time. |
The value of increment cannot be higher than the value of the interval.
Cornélissen, G. (2014). Cosinor-Based Rhythmometry. Theoretical Biology and Medical Modeling, 11, Article 16.
ssections(data = PANAS_november, time = PANAS_time, period = 7, interval = 7, increment = 1)
ssections(data = PANAS_november, time = PANAS_time, period = 7, interval = 7, increment = 1)
A dataset containing the air temperature in Zagreb on July 1, 2015.
temperature_zg
temperature_zg
A data frame with two variables:
Air temperature in Zagreb on July 1, 2015.
Time of the day when the temperature was measured.
Measurements were taken every 30 minutes throughout the whole day.
Croatian Meteorological and Hydrological Service, http://www.meteo.hr