Related Experiment Video
Updated: Jan 10, 2026

A Method of Trigonometric Modelling of Seasonal Variation Demonstrated with Multiple Sclerosis Relapse Data
Published on: December 9, 2015
A SAS macro for multilevel Cosinor analysis
Margaret M Doyle1, Terrence E Murphy2, Brienne Miner1
1Section of Geriatrics, Department of Internal Medicine, Yale School of Medicine, New Haven, CT, USA.
Background And Objective:
Cosinor analysis allows for the fitting of a cosine curve to describe cyclical variation in periodic data. The analysis provides an intuitive set of estimates that includes the MESOR (Midline Estimating Statistic of Rhythm), i.e., the mid-point of the fitted outcome, the amplitude, i.e., one-half the distance between the MESOR and the peak for normally distributed outcomes, and the acrophase, i.e. the time at which the outcome reaches its peak. Traditionally, most published cosinor analyses were generated though a two-stage approach in which a curve was fit to each individual's data and differences in the estimated cosinor parameters were compared in downstream analyses. More recently multilevel cosinor modeling software has been developed which allows for the simultaneous modeling of data from multiple individuals. In addition to simplifying the model building process, the advantage of multilevel vs. two-stage cosinor analysis includes the option to fit more complex models and, likely, an improvement in fit for each individual's data. However, to our knowledge, there are no SAS procedures or macros that assist users with this analytical approach.
Methods:
In this paper we introduce multilevel cosinor models and SAS macros we have developed to perform these analyses. In addition, we compare model fit between the multilevel and two-stage methods.
Results:
The SAS macros presented in this paper allow users to select the best random variable specification for the unconditional cosinor model and add a dichotomous grouping variable to detect differences in parameters across groups. At each step of model building, parameter estimates, measures of model fit and graphical output help the user understand the model derived and its appropriateness for their data. Results of cross-validation analyses are presented that illustrate the superior fit of the multilevel over the single-level approach for the dataset utilized in the examples.
Conclusions:
Multilevel cosinor analysis extends the single subject cosinor model by allowing for more convenient model selection and may provide a better fit for each individual's data. We are hopeful that this manuscript will introduce more researchers to this analytical technique and allow them to apply it in their own research.
Related Concept Videos
Statistical Analysis System (SAS)
Applications: SAS finds applications in numerous fields, including healthcare for clinical trial analysis, finance for risk assessment, marketing for customer data analysis, and...
The Law of Cosines
Direction Cosines of a Vector
Graphical and Analytic Representation of Sinusoids
The first step is measuring the peak-to-peak value, which is twice the amplitude of the sinusoid. This provides information about the maximum voltage swing of the waveform.
Secondly, the period and angular frequency are determined. The period is the time taken for one complete cycle of the waveform, while...
2D NMR: Homonuclear Correlation Spectroscopy (COSY)
Microsoft Excel: Regression Analysis
To perform regression...

