I am working on completing some cosinor analysis on some activity data of mine. I am attempting to run the cosinor.lm command, yet keep getting this error which states that my time column is not in the correct format.
cosinor.lm(Activity ~ time(Time) + Bird + Sex, data=data.set, period = 24, na.action = na.omit)
"Error in 2 * pi * data[, timevar] :
non-numeric argument to binary operator"
I have tried converting the time column to numeric value, but because of the colons in the time column format, R returns the values as "NA". Does anybody know how I can fix this?
Any problem in R can be approached with advantage using the basic idea of school algebra: f(x) = y where the three objects are
x, called an argument, which is what is at hand, in this case a vector of strings representing HH:MM:SS
y the object that is desired
f a function, which may be composed to transform x to y.
There are regression methods meant to work with time series specifically that be considered if the time data are more variable. The Time variable might, in this case of ordinary least square regression be treated as a categorical variable since it seems, a priori, unlikely that Activity varies continuously with the passage of time. However, the conversion below assumes that seconds is the appropriate measure.