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 ?

Thank you in advance

  • $\begingroup$ The best package for panel data in R is plm. You can find more info here $\endgroup$
    – Stereo
    Feb 28, 2017 at 17:13

1 Answer 1


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:


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

predict(my.model, test.data)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.