1
$\begingroup$

I have received some data that contains measurements of vehicle speed in function of time of day. The point is to predict speed for this measure point at any given time of day.

I'm using R so I tried to fit a glm but it seems to be able to fit only a straight line. This obviously requires a more advanced model that captures peak hours.

Output in R

Can someone point me in the right direction? I've been thinking of trying gam, or splines.

$\endgroup$

1 Answer 1

1
$\begingroup$

There are indeed splines implemented in R; look at ?spline.

That said, your data does not exhibit any obvious structure. It's not clear to me that anything more sophisticated than a straight line will yield better predictions. (A more complicated model will incur higher variance on parameter estimates, which in turn will increase the prediction error. Sometimes a simple wrong model will yield better predictions than a more complex correct one.)

$\endgroup$
1
  • 1
    $\begingroup$ There should be dips at peak hours. I have a few measurement locations and some of those do exhibit some form of a structure. $\endgroup$
    – bulbanos
    May 19, 2016 at 14:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.