Questions tagged [plm]

R package primarily concerned with panel data. Package contains a set of estimators and tests for panel data.

510 questions
3
votes
5 answers

Merge plm fitted values to dataset

I'm working with a fixed effects regression model using plm. The model looks like this: FE.model <-plm(fml, data = data.reg2, index=c('Site.ID','date.hour'), # cross section ID and time series ID model='within', #coefficients…
Luna
  • 39
  • 1
  • 5
3
votes
1 answer

Why PLM creates massive objects and fails to open them

I am working on a large (but not enormous) data base of 1.1mln observations x 41 variables. Data are arranged as an unbalanced panel. Using these variables I specified three different models and I run each of them as a 1) fixed effects, 2) random…
Riccardo
  • 743
  • 2
  • 5
  • 14
3
votes
1 answer

deleting rows for which there are too many NA values in a PLM data frame

I am working with a rather large panel of data on 180 countries from 1950 to 2003. I have been using the plm package in R. One thing I need to do is remove countries for which there are too few GDP observations, or, in other words, too many NA's.…
crf
  • 1,810
  • 3
  • 15
  • 23
3
votes
3 answers

fixed effect, instrumental variable regression like xtivreg in stata (FE IV regression)

Does anyone know about a R package that supports fixed effect, instrumental variable regression like xtivreg in stata (FE IV regression). Yes, I can just include dummy variables but that just gets impossible when the number of groups increases.…
user2503795
  • 4,035
  • 2
  • 34
  • 49
2
votes
0 answers

Estimation problem with Difference in Difference - Within model twoways effect

I need to estimate a difference-in-difference regression to understand the effect of a policy on various municipalities. I have a dataset that spans from 2001 to 2019, covering almost 7,900 municipalities. I am using R for the analysis. I have a…
M_B
  • 21
  • 2
2
votes
1 answer

Predict out of sample on fixed effects model with fixest

Is there a way to make predictions from a fixest model on an observation that has an out-of-sample fixed effects level? I would like this prediction to be based on the weighted mean of the existing fixed effects levels in the training data. For the…
dufei
  • 2,166
  • 1
  • 7
  • 18
2
votes
1 answer

stargazer output several models R

I run three different estimations of panel linear models (fixed effects model with two fixed effect (id and year)). fixed_YIELD_mean_to_treat.100 <- plm(YIELD_mean_total ~ treated.100 + Nightlight_sum + Population_sum + temp_mean, data= Results,…
Sulz
  • 333
  • 1
  • 8
2
votes
1 answer

plm::lag isn't lagging. How to deal with lags in panel data

I've scoured SO and it seems others have had this same question, but the solutions aren't working for me. I have a reprex for you as follows: name<-c("Jim", "Jim", "Jim", "Bob", "Bob", "Bob") number<-c(1,2,3,1,2,3) panel<-data.frame(name,…
2
votes
1 answer

Predict on test data, using plm package in R, and calculate RMSE for test data

I built a model, using plm package. The sample dataset is here. I am trying to predict on test data and calculate metrics. # Import package library(plm) library(tidyverse) library(prediction) library(nlme) # Import data df <- read_csv('Panel data…
Anakin Skywalker
  • 2,400
  • 5
  • 35
  • 63
2
votes
1 answer

lag() from pglm seems to bug lag() from stats

As the title says. After I load pglm, lag stops to work properly. library(pglm) c(1,2,3,4) %>% lag() the object is converted into a time series and is not compatible anymore with tibbles. Even unloading pglm, the dependency for lag is still…
GiulioGCantone
  • 195
  • 1
  • 10
2
votes
0 answers

System is exactly singular error when using pgmm (plm-package) in R

I am new to the plm package, but I need to do a system gmm on a dataset for my bachelor thesis in economics. I am trying to regress the GDP on the amount of railways stations built. This includes of course a lagged GDP variable and other controls,…
DLTS
  • 21
  • 3
2
votes
1 answer

What is the meaning of "|" in R

I'm watching a video on YouTube about linear regression, one line of code is like this (function pgmm of package plm): model1 = pgmm(democracy~lag(democracy)+lag(income)|lag(democracy, 2:99), DemocracyIncome25, index=c("country", "year"),…
2
votes
2 answers

R - Panel data FE, no unique time-id match, creating new time-variable

I am working with a highly disaggregated unbalanced panel data set in the long format on vehcile sales and want to run a FE regression model. The data structure is given like that (of course containing further information, but this is irrelevant for…
Joschka
  • 21
  • 3
2
votes
2 answers

R package alternative to plm for panel data

I have been googling quite a lot and only found the plm package as a comprehensive package of tools for handling and analyzing panel data in R. I am a novice in the field but will have to perform some analyses for my Master Thesis. Do you have any…
corkinabottle
  • 141
  • 1
  • 7
2
votes
2 answers

Warning message in R plm package regarding indexes that have the same length but not the same content

I get a warning message from the plm package in R when I perform ´summary()´ of a model: 1: In Ops.pseries(y, bX) : indexes of pseries have same length but not same content: result was assigned first operand's index 2: In Ops.pseries(y, bX) : …
noslomo
  • 58
  • 7