Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

r

plm

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.

like image 445
Eric Avatar asked Jul 15 '17 19:07

Eric


People also ask

What is PLM package in R?

plm is a package for R which intends to make the estimation of linear panel models straightforward. plm provides functions to estimate a wide variety of models and to make (robust) inference. Details For a gentle and comprehensive introduction to the package, please see the package's vignette.

What is a PLM model?

Product Lifecycle Management (PLM) is an integrated business approach to the collaborative creation, management and dissemination of engineering information throughout the extended enterprise.

What does index mean in PLM in R?

The index argument indicates the dimensions of the panel. It can be: a vector of two character strings which contains the names of the individual and of the time indexes, a character string which is the name of the individual index variable.


1 Answers

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").

like image 139
Helix123 Avatar answered Nov 15 '22 00:11

Helix123