I have a time series of hourly activity levels for a period of about 2 months (1704 observations). There is obviously a strong "seasonal" component (freq=24) to this time series, with activity showing daily fluctuations between night and day.
I'm interested in looking at the relationship between hourly activity and environmental variables, but I'm thinking I need to remove the seasonality first, because otherwise there is a strong positive relationship between activity and air temperature - but that would mostly be because it's warmer during the day and we're more active during the day - but what I would like to find out is if we are more active on warm days than on cold days, and how much of a lag there is between increasing temp and increasing activity.
I ran some cross-correlation functions to try and address these questions, but I think the strong 24 hour cyclicity is affecting those results. I've decomposed the time series using "decompose" in R, which is neat, but I don't know how to use that information to give an actual, deseasonalized time series to work with.
Here is a sample of the data:
[1] 24 16 40 48 50 38 24 4 4 5 3 6 4 4 4 3 12 63 55 42 56 20 10 26 45 47 66 64 59
[30] 54 24 5 6 2 4 3 6 10 6 2 13 39 26 17 24 13 19 26 17 32 54 68 58 39 20 0 3 2
[59] 8 2 4 1 5 11 5 60 57 54 40 40 53 74 40 42 57 46 46 26 9 8 4 6 14 8 5 3 2
[88] 7 19 47 53 43 53 51 55 64 48 64 57 56 52 34 22 8 5 6 4 6 3 4 7 6 27 40 48 41
[117] 43 51 50 44 56 64 68 46 49 35 16 2 14 3 7 3 13 3 3 2 14 49 62 42 41 57 52 63 32
[146] 54 59 60 68 24 12 2 2 2 2 7 6 5 9 10 26 53 50 59 28 45 47 44 48 55 59 77 86 33
[175] 18 16 10 6 9 9 14 7 9 7 9 46 57 41 33 32 34 29 39 39 27 26 4 10 9 6 6 2 4
[204] 1 2 2 4 4 17 50 47 24 27 34 26 38 20 6 20 15 25 8 2 2 3 6 4 3 3 4 4 2
[233] 18 41 63 52 37 32 32 28 48 20 6 10 9 7 5 10 4 3 4 7 4 3 4 10 8 56 47 50 27
[262] 30 22 38 38 28 33 24 18 12 14 2 10 4 21 4 5 6 4 4 20 41 46 16 8 20 24 21 16 27
[291] 10 6 14 5 6 6 12 2 10 7