# Estimating panel model in R

How can I estimate

$y_{i,t}=β_{i}x_{i,t}+ϵ_{i,t} \\ β_{i}=γ_{i}z_{i}+η_{i}$

in R ? Moreover, if I have splitted my data set to a train set which will contain 80% of all the i's and then I want to forecast the $y_{i,t}$ for the rest 20% i's $\forall t$, how can I do it in R ?

• The best package for panel data in R is plm. You can find more info here Feb 28 '17 at 17:13

For linear regression you want to use R's lm() function, like this:

my.model <- lm(response.variable ~ predictor1 + predictor2, data = my.data)


Look at the model using:

summary(my.model)


You can apply this model to a "test" dataset (your 20% split) by using predict(), like this:

predict(my.model, test.data)