Panel data regression (R)- temperatures at weather stations correlated across time and across stations

I have a balanced panel dataset with a few dozen weather stations' hourly temperature readings across several decades. I have a measure of population density around the weather station over time as well as the latitude and altitude of the weather station (which remain fixed). I have been tasked with estimating the average effects of population density on temperatures and the average effect of time, hoping to disentangle the urban heat island effect from overall climate change.

I can put all observations into a linear model in R quite easily, controlling for altitude and latitude, but I know this violates the regression assumption of independence. Weather across stations is highly correlated at any given time, and any given observation is highly dependent on the previous hour at that station. I know that there may be unobserved heterogeneity between stations not explained by latitude and altitude, but fixed effects might bias my coefficient on population density because cities change slowly over time. It has been several years since I took an econometrics course (in STATA), so I am stuck knowing that something is wrong but not understanding the correct way to estimate the effect of population density and year.

I have tried the plm package in R, but the arguments are a bit overwhelming, and I am having trouble finding documentation or examples of a similar problem written to my knowledge level. Thank you!

• Very interesting data and modeling problem! One initial thought is that one of the problems you'll need to get right is the autocorrelation you mention in terms of prior hour's weather being highly correlated with the weather at the next hour. If you were using generalized linear mixed models, which is one viable approach given the data structure, you will need to account for this autocorrelation by modeling it in the occasion-specific residuals (e.g., AR(1) or AR(2)). Also, how would you like to measure the time effect? Hourly, daily, yearly? Dec 12, 2019 at 19:41
• I was about to make much the same comment as @ErikRuzek . Additionally, have you looked at the climate-science literature, and this must be a very common modelling scenario there ? Dec 12, 2019 at 19:42
• Thank you for the suggestions. So far I have measured time by just using Year as a variable. I looked through a lot of literature in the climate science literature, but their data and methods are significantly more complex than what I can do. I am basically attempting to see if I can find support for their conclusions with the data I have available.
– Alex
Dec 12, 2019 at 19:53
• Can you elaborate on how often each of your variables - dependent and independent - were measured? Hours, days, months, years, etc. Dec 12, 2019 at 20:00
• Yes, the population around each station was measured annually. Temperature was measured hourly for every hour across several decades. Latitude and Altitude are fixed for each station across time.
– Alex
Dec 12, 2019 at 20:03