Cosinor analysis uses the least squares method to fit a sine wave to a
time series. Cosinor analysis is often used in the analysis
of biologic time series that demonstrate predictible rhythms. This
method can be used with an unequally spaced time series.
Follows cosinor analysis of a time series as outlined by
Nelson et al. "Methods for Cosinor-Rhythmometry" Chronobiologica.
1979. Please consult reference.
t - time series
y - value of series at time t
w - cycle length, defined by user based on prior knowledge of time
alpha - type I error used for cofidence interval calculations. Usually
set to be 0.05 which corresponds with 95% cofidence intervals
Note: Statistics toolbox is necessary only to caculate t and F distributions for the number of samples at the specified alpha. These values could be obtained from a table and manually inserted in the code, thus negating the use of the statistics toolbox.
I'm getting the following message:
"Confidence region overlaps the pole. Confidence limits for Amplitude and Acrophase cannot be determined"
Why the confidence region overlaps the pole? Why cannot the confidence limits for amplitude and acrophase be determined? What can I do to solve this?
It seems that unequal sampling problem can be resolved by addition ~isnan(y) to every value in NE matrix. Thus 2) is not an issue. :)
UPD: 3) added by mistake
I am by no means a specialist in Matlab, but there are several comments:
1) In section "Confidence interval for the mesor" is written 'sigma^2', whereas according to Nelson et al, 1979 and Bingham et al., 1982 it should be 'sigma'.
This leads to inflated estimation of mesor CI.
2) This code is can not be used for data sets with missing values - only equally spaced and full time series thus simplified estimation of M, beta and gamma can be applied as shown in Nelson et al.,1979.
3) According to Nelson et al., 1979 t should be computed for two-tailed distribution, thus 1-alpha/2 should be used.
Wouldn't the p-value for the zero-amplitude test have to come from the F-distribution's CDF, rather than its PDF?
Undefined function or variable "phi".
Error in ==> cosinor at 94
fprintf(1,'Mesor = %g \nAmplitude = %g \nAcrophase = %g \n\n',M,Amp,phi);
The published example should run to completion. The statistics toolbox is necessary. Please post if there are any additional problems.
The published example does not run to completion. The error message is:
??? Undefined function or method 'tinv' for input arguments of type 'double'.
Error in ==> cosinor at 121
CI_M = tinv(1-alpha/2,n-3)*sigma^2*sqrt(((sum(x.^2))*(sum(z.^2)) - (sum(x.*z))^2)/(n^3*(X*Z - T^2))); %#ok<NASGU>
Either this m-file depends on a toolbox not identified here, or something has been left out of the submission.
There is a bug in the published M-file!!!
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.