I have a question I met in my project.
I have a panel data, including 20 cities and there are 18 years OBS (x and y) for each city. I want to establish a equation with dummy variables for control time-invariant city-specific characteristics and control for time trend.
Thus my equation is:
Y = a1 + a2*X + a3*D_city + a4*D_year (1)
Where, D_city and D_year are dummiy variables for controling variant of city and time. So I have two dummy variables.
But If I do that, is it correct that I actually assumed a common time trend for each city? (question 1)
It maybe not correct since each city has their own time trend features. So I want to give a city-specific time trend.
Thus I have another function form:
Y = a1 + a2*X + a3*D_city + a4*D_city*year (2)
Others are the same with previous function except the last term which I multiple D_city with value of year.
So the equ(2) could change to
Y = a1 + a2*X + D_city(a3 + a4*year) (3)
In the form, can I say I considered city-specific time trend? (question 2)
Finally, I tried the equ(2) in R by inputting:
result<-lm(Y~X + D_city + D_city*year,data)
But I don't think R gave me the result I need. How can I do this? (question 3)