7

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.

2
  • 1
    Please see this link to learn how to make a reproducible example: stackoverflow.com/questions/5963269/… Commented Jul 15, 2017 at 21:43
  • Try to create a pdata.frame first and use it the data argument. See the package's vingette for how to do this. Commented Jul 16, 2017 at 9:37

1 Answer 1

8

This is likely a problem with your data: As it seems, the variables VerbalScore and Method do not vary per individual. Thus, for the Swamy-Arora RE model (default) the within variance necessary cannot be computed. Affected variables drop out of the model which are here all RHS variables and you get the (not very specific) error message empty model.

You can check variation per individual with the command pvar().

If my assumption is true and still you want to estimate a random effects model, you will have to use a different random effect estimator which does not rely on the within variance, e.g. try the Wallace-Hussain estimator (random.method="walhus").

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.