[R] LM() and time in R

Livia Maria Vestergaard lvest09 at student.sdu.dk
Thu Apr 30 10:06:08 CEST 2015

Hello guys, 
thanks for your quick reply 
I will try and specific my problem 

I have over 300.000 observations for different petrol pumps in all of Denmark fra 1. november 2014 - 31 january 2015
for example I have: 

petrol pump number:  "1111" /  date: 1. november 2014 / time: 08:14:22 / price: 10.55 /day /   zipcode: 2000
petrol pump number:  "1111" /  date: 1. november 2014 / time: 08:29:00 / price: 10.52 / day / zipcode: 2000
petrol pump number: "3456" / date: 1. november 2014 / time: 08:19:21 / price: 10.88 / day/  zipcode: 2100

And then put the zip codes into dummy categories like X1: zipcode (1000-2000)=1 all others 0 and so on.

My regression model then look like 

lm(price, x1 + x2 + x3 ...  ) but the "Multiple R-squared" is really low, 0.01217 

So instead I would like to check if the time "hh:mm:ss" have an effect on the price. I know how to tell R about the date by as.Date() , but not with the time, how can I do that? 

Or do you guys maybe a third idea about what should make a regression about to improve the model?

Livia :) 

Fra: Boris Steipe [boris.steipe at utoronto.ca]
Sendt: 29. april 2015 20:25
Til: Livia Maria Vestergaard
Cc: r-help mailing list
Emne: Re: [R] LM() and time in R

Have a look at the help page for the function ts()
(type ?ts  at the R prompt).  Other than that, you haven't provided nearly enough information for us to diagnose your issue.

Please see here for some hints on how to ask questions productively:


On Apr 29, 2015, at 6:26 AM, Livia Maria Vestergaard <lvest09 at student.sdu.dk> wrote:

> Hello,
> I need some help with a project that I’m working one.
> Im trying to make a l regression model (lm) in r with time as independant variable and gas prices as the depended.
> But It seems like everything im trying to run it, R freeze, I think that I need to tell R somehow that my time is time but how ?
> Hope that you can help me :)
> Livia
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list