How to specify the periodicity of an angular predictor (`sun_altitude`) in a regression model?

76 views Asked by At

I am using the package momentuHMM in R, which analyses data using Hidden Markov Models. However, coefficient estimates are calculated using linear regressions.

If I would want to use Hour (format: 24 h) as a predictor variable of a given Ydependent variable, I should specify Y ~ cosinor(Hour, period = 24). The cosinor function automatically incorporates both the sin() and cos() as well as their interaction.

I wonder which value I should indicate in period of the mentioned function cosinor() if I use the variable sun_altitude, for which values range between -1.3 (night) and 1.2 (midday). What should I indicate in period? 2.5?. My doubt comes because Hour and sun_altitude are different in the sense that for Hour, after the value 23, the next value is 00, so the maximum and minimum value of this predictor is closer that, for instance, 00 and 12. However, it is not the same with sun_altitude, since a value of 0 and a value of 1.2 are closer than between 1.2 and -1.2. That is, for sun_altitude the maximum and minimum value of the variable are not closer between them than between the minimum and medium values.

Should I consider that when specifying period?

Below I show some code to create a dataframe with sun_altitudes just in case someone wants to take a look:

df <- seq(as.POSIXct("2016-07-29 00:00:00", format="%Y-%m-%d %H:%M:%S",tz="UTC"), as.POSIXct("2016-07-31 23:45:00", format="%Y-%m-%d %H:%M:%S",tz="UTC"), "15 min")
df<- as.data.frame(df)
colnames(df)<- c("Round_datetime15")
df[2]<-getSunlightPosition(date=df$Round_datetime15, lat= 37.6, lon=-0.65, keep = ("altitude"))[4]
range(df$altitude)

Note: maximum and minimum values of the sun altitude are not reached in one day. The maximum value of the sun is reached in summer and the minimum value in winter.

1

There are 1 answers

0
Théo Michelot On

I don't have enough reputation to comment so I'm posting this as an answer.

It is not clear to me why you would include a periodic effect of sun altitude in that situation. As you mention in the case of the time of day, a periodic effect should be considered when the two ends need to match (e.g., the effect of time of day should be very similar at 23:59 and 00:00). From what you write, it doesn't sound like the effect of sun altitude should match at -1.3 and 1.2, so I don't think that you need the cosinor function.

So, I think you can just include the covariate as is in your formula, i.e., ~ sun_altitude.