R package primarily concerned with panel data. Package contains a set of estimators and tests for panel data.
Questions tagged [plm]
510 questions
19
votes
5 answers
Is there a predict function for plm in R?
I have a small N large T panel which I am estimating via plm::plm (panel linear regression model), with fixed effects.
Is there any way to get predicted values for a new dataset? (I want to
estimate parameters on a subset of my sample, and then use…

Ram Ahluwalia
- 1,092
- 1
- 10
- 25
18
votes
2 answers
Heteroscedasticity robust standard errors with the PLM package
I am trying to learn R after using Stata and I must say that I love it. But now I am having some trouble. I am about to do some multiple regressions with Panel Data so I am using the plm package.
Now I want to have the same results with plm in R as…

Marcus R
- 245
- 1
- 2
- 8
14
votes
4 answers
plm: using fixef() to manually calculate fitted values for a fixed effects twoways model
Please note: I am trying to get the code to work with both time & individual fixed effects, and an unbalanced dataset. The sample code below works with a balanced dataset.
See edit below too, please
I am trying to manually calculate the fitted…

Peter
- 1,016
- 9
- 20
13
votes
4 answers
Double clustered standard errors for panel data
I have a panel data set in R (time and cross section) and would like to compute standard errors that are clustered by two dimensions, because my residuals are correlated both ways. Googling around I found…

Alex
- 19,533
- 37
- 126
- 195
13
votes
1 answer
plm or lme4 for Random and Fixed Effects model on Panel Data
Can I specify a Random and a Fixed Effects model on Panel Data using lme4?
I am redoing Example 14.4 from Wooldridge (2013, p. 494-5) in r. Thanks to this site and this blog post I've manged to do it in the plm package, but I'm curious if I can do…

Eric Fail
- 8,191
- 8
- 72
- 128
12
votes
1 answer
Test for Multicollinearity in Panel Data R
I am running a panel data regression using the plm package in R and want to control for multicollinearity between the explanatory variables.
I know there is the vif() function in the car-package, however as far as I know, it cannot deal with panel…

David
- 9,216
- 4
- 45
- 78
11
votes
1 answer
Clustered standard errors different in plm vs lfe
When I run a cluster standard error panel specification with plm and lfe I get results that differ at the second significant figure. Does anyone know why they differ in their calculation of the…

kennyB
- 1,963
- 3
- 17
- 22
10
votes
1 answer
first-difference linear panel model variance in R and Stata
I would like for a colleague to replicate a first-difference linear panel data model that I am estimating with Stata with the plm package in R (or some other package).
In Stata, xtreg does not have a first difference option, so instead I run:
reg…

dimitriy
- 9,077
- 2
- 25
- 50
10
votes
1 answer
How to deal with NA in a panel data regression?
I am trying to predict fitted values over data containing NAs, and based on a model generated by plm. Here's some sample code:
require(plm)
test.data <- data.frame(id=c(1,1,2,2,3), time=c(1,2,1,2,1),
y=c(1,3,5,10,8), x=c(1, NA, 3,4,5))
model <-…

Rodrigo
- 473
- 4
- 14
9
votes
2 answers
R - Plm and lm - Fixed effects
I have a balanced panel data set, df, that essentially consists in three variables, A, B and Y, that vary over time for a bunch of uniquely identified regions. I would like to run a regression that includes both regional (region in the equation…

Jasper
- 133
- 1
- 2
- 8
9
votes
2 answers
Weights with plm package
My data frame looks like something as follows:
unique.groups<- letters[1:5]
unique_timez<- 1:20
groups<- rep(unique.groups, each=20)
my.times<-rep(unique_timez, 5)
play.data<- data.frame(groups, my.times, y= rnorm(100), x=rnorm(100), POP= 1:100)
I…

Zslice
- 412
- 1
- 5
- 14
9
votes
0 answers
Error with panel data (plm) Error in crossprod(t(X), beta)
I have a df (a pdata.frame object):
head(df) :
Company Year Kapitalinkomster Bank.o.kassa Obligationer Lån Aktier Placeringar.andra.ftg Fodringar Reala.tillgångar
5-1948 5 1948 4.009780 0.8677505 40.12268…

user1665355
- 3,324
- 8
- 44
- 84
8
votes
2 answers
Clustered standard errors in R using plm (with fixed effects)
I'm trying to run a regression in R's plm package with fixed effects and model = 'within', while having clustered standard errors. Using the Cigar dataset from plm, I'm running:
require(plm)
require(lmtest)
data(Cigar)
model <- plm(price ~ sales +…

user5450835
- 83
- 1
- 1
- 3
8
votes
3 answers
Fixed Effects Regression with Interaction Term Causes Error
I am trying to estimate a panel dataset with an interaction term for geographical areas (LoadArea, DischargeArea) which signifies a route. Using the fixed effects specification, it does not like the interaction term (LoadArea * DischargeArea) and…

Sassafras
- 301
- 5
- 16
8
votes
1 answer
R: plm -- year fixed effects -- year and quarter data
I am having a problem setting up a panel data model.
Here is some sample data:
library(plm)
id <- c(1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2)
year <- c(1999,1999,1999,1999,2000,2000,2000,2000,1999,1999,1999,1999,2000,2000,2000,2000)
qtr <-…

Brad
- 813
- 1
- 10
- 20