plm Package in R - empty model when including only variables without variation over time per individual

Viewed 8973

I have a dataframe ('math') like this (there are three different methods, although only one is shown) - dataframe

I am trying to create a multi-level growth model for MathScore, where VerbalScore is an independent, time invariant, random effect.

I believe the R code should be similar to this -

random <- plm(MathScore ~ VerbalScore + Method, data=math, index=c("id","Semester"), 
              model="random")

However, running this code results in the following error:

Error in plm.fit(object, data, model = "within", effect = effect) :
empty model

I believe it's an issue with the index, as the code will run if I use:

random <- plm(MathScore ~ VerbalScore + Method + Semester, data=math, index="id", 
              model="random")

I would be grateful for any advice on how to create a multi-level, random effect model as described.

1 Answers
Related