9.1 Fixed and Random effects using the plm package

  • The argument in is set to for fixed effects model and for a random effects model.

  • The data can be converted to the required panel format using function, which transforms a regular data frame object into a panel data structure.

  • is the main argument in the function which specifies the panel structure, i.e, columns with individual and time variables.

# Grunfeld Data representation as per pdata.frame function
library(plm)
data(Grunfeld)  #load data
head(Grunfeld)  #data snapshot
  firm year   inv  value capital
1    1 1935 317.6 3078.5     2.8
2    1 1936 391.8 4661.7    52.6
3    1 1937 410.6 5387.1   156.9
4    1 1938 257.7 2792.2   209.2
5    1 1939 330.8 4313.2   203.4
6    1 1940 461.2 4643.9   207.2
pdata1 = pdata.frame(Grunfeld, index = c("firm", "year"))
head(pdata1)
       firm year   inv  value capital
1-1935    1 1935 317.6 3078.5     2.8
1-1936    1 1936 391.8 4661.7    52.6
1-1937    1 1937 410.6 5387.1   156.9
1-1938    1 1938 257.7 2792.2   209.2
1-1939    1 1939 330.8 4313.2   203.4
1-1940    1 1940 461.2 4643.9   207.2