# A better fit for sinusoidal data

I have been struggling to fit my data to a sine curve.

My data looks like:

frame = data.frame(hour = c(0, 1, 2, ... 24), value = (numbers between 0 and 500))


I have the following model:

It doesn't model much. Adjusted R squared of .1836.

Here is the plot:

Histogram of log(value)

Plot of log(value)

As a time series

• judging from your plot you should not expect to get higher R^2 value, because you have a whole range of response for a single hour. Nov 22 '14 at 7:00
• @KarolisKoncevičius so how can I better model this then? Nov 22 '14 at 7:01
• If you don't have external causal variables that explain why a particular value at 10am is high rather than low, you won't be able to model it better. "Noise" is whatever you don't know about, and you apparently have a lot of it. Nov 22 '14 at 7:09
• Your response appears to be strictly positive. You might be better off with a GLM perhaps. What does the response consist of? Nov 22 '14 at 8:59
• There's at least some suggestion from that information that a gamma model might be reasonable for the conditional distribution. Alternatively, you might want to consider whether some kind of time series model in the logs (possibly AR, say, perhaps with regressors as well). It may that there's simply a lot of noise. One thing that has me curious is why a period like 50*hour? Was that deliberately chosen? Nov 22 '14 at 15:00