# Cosinor Analysis - How to add more cycles

When I run the "ggplot.cosinor.lm" I only get 1 cycle. How can I add more cycles with 24 hour periods to cover all of my values? Thank you!

``````library(cosinor)

dat <- read_excel("~/Desktop/PSYC 493.xlsx", sheet = "Single Cosinor example")

rdat <- data.frame (x=c(dat\$Time), y=c(dat\$Measurement))

# This is my data: X is my time points and y is my corresponding measurements.
rdat <- structure(list(x = c(9.2, 11.07, 13.02, 15.17, 17.02, 19, 21.02,
23, 25.09, 27.02, 29, 31.04, 33, 35.09, 37.07, 39.1, 40.54, 41.52,
42.52, 43.52, 44.52, 45.52, 46.54, 47.52, 48.59, 49.62, 50.57,
51.54, 52.54, 54.05), y = c(3.8, 3.7, 3.9, 3.6, 3.8, 3.9, 3.7,
3.9, 3.8, 3.8, 3.9, 3.9, 3.8, 3.8, 4.1, 3.9, 3.9, 4, 4.1, 3.9,
3.8, 4, 3.9, 3.8, 3.9, 3.8, 3.7, 3.8, 3.8, 3.8)), class = "data.frame", row.names = c(NA,
-30L))

fit <- cosinor.lm(y ~ time(x),period = 24, data = rdat)
ggplot.cosinor.lm(fit)
``````

Created on 2021-10-12 by the reprex package (v2.0.1.9000)

I am assuming that you have data with time points that exceed 24 hours or more than 1 day and you want to have individual cycles for each day?
If so you will have to fit it individually.

What would really help is if you post a snippet of your data,output and expected output so we can better help you. Have a look at the 'reprex' package to make this easier for you to post

You are right. My time data exceeds 24 hours. It starts at 9:20 and ends at 54.05. I would like to have continuous waves (multiple 24hr cycles) until my end time. Could you please expand on how I need to fit it individually? Here is a snippet of my data.
Many thanks!

``````library(cosinor)

dat <- read_excel("~/Desktop/PSYC 493.xlsx", sheet = "Single Cosinor example")

rdat <- data.frame (x=c(dat\$Time), y=c(dat\$Measurement))

fit <- cosinor.lm(y ~ time(x),period = 24, data = rdat)
ggplot.cosinor.lm(fit)
``````

Created on 2021-10-07 by the reprex package (v2.0.1.9000)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.