Hello,
For my thesis I am analyzing a regression with panel data from 27 countries from 1995-2019, which is quarterly data. This panel data consists of GDP which is my dependent variable, investment growth rate + government spending + life satisfaction + unemployment rate, which are all independent variables and predetermined. Besides it includes some variables which are measuring the seriousness of terrorism. my independent variables need to be interacted with my year (1995-2019), but this is not working. Can somebody help me with this?
Firstly i made all the variables in factors
year <- as.factor(data$Year)
unemp <- as.factor(data$unemp)
invgr <- as.factor(data$invgr)
govspen <-as.factor(data$govspending)
happy <- as.factor(data$happy)
then i tried to interacted them with the time variable
time_inter <- year:unemp
time_inter2 <- year:invgr
time_inter3 <- year:govspen
time_inter4 <- year:happy
and then turn it in my regressions:
reg1 <- lm(gdpgr~time_inter+time_inter2r+success+factor(Country)+factor(Year), data=data)
which gave me this error:
Error in contrasts<-
(*tmp*
, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels
can someone help me with this?