ranef.plm {plm} | R Documentation

## Extract the Random Effects

### Description

Function to calculate the random effects from a `plm` object (random effects model).

### Usage

    ## S3 method for class 'plm'
    ranef(object, effect = NULL, ...)

### Arguments

`object` | an object of class `"plm"`, needs to be a fitted random effects model,
`effect` | `NULL`, `"individual"`, or `"time"`, the effects to be extracted, see Details,
`...` | further arguments (currently not used).

### Details

Function `ranef` calculates the random effects of a fitted random effects model. For one-way models, the effects of the estimated model are extracted (either individual or time effects). For two-way models, extracting the individual effects is the default (both, argument `effect = NULL` and `effect = "individual"` will give individual effects). Time effects can be extracted by setting `effect = "time"`.

Not all random effect model types are supported (yet?).

### Value

A named numeric with the random effects per dimension (individual or time).

### Author(s)

Kevin Tappe

### See Also

`fixef` to extract the fixed effects from a fixed effects model (within model).

### Examples

    data("Grunfeld", package = "plm")
    m1 <- plm(inv ~ value + capital, data = Grunfeld, model = "random")
    ranef(m1) # individual random effects

    # compare to random effects by ML estimation via lmer from package lme4
    ## Not run:
      library(lme4)
      m2 <- lmer(inv ~ value + capital + (1 | firm), data = Grunfeld)
      cbind("plm" = ranef(m1), "lmer" = unname(ranef(m2)$firm))

    ## End(Not run)

    # two-ways RE model, calculate individual and time random effects
    data("Cigar", package = "plm")
    tw <- plm(sales ~ pop + price, data = Cigar, model = "random", effect = "twoways")
    ranef(tw)                   # individual random effects
    ranef(tw, effect = "time")  # time random effects

[Package plm version 1.6-6 Index]