Questions tagged [panel-data]

A multidimensional dataset usually describing measurements over time for a specific cohort.

Panel data is a dataset that is focused, multivariate longitudinal data for a set of cross-sectional units such as a family or an individual. Many statistical analysis libraries require the data to be formatted in a certain manner.

854 questions
7
votes
0 answers

How to structure panel data for LSTM and Keras?

I am trying to figure out how to structure my dataset and build the X and y such that it will work with Keras' Stacked LSTM for sequence classification. I have panel data where I am trying to predict classifications. I am not entirely sure how to…
John Stud
  • 1,506
  • 23
  • 46
7
votes
2 answers

Pandas read_csv with different date parsers

I have a csv-file with time series data, the first column is the date in the format %Y:%m:%d and the second column is the intraday time in the format '%H:%M:%S'. I would like to import this csv-file into a multiindex dataframe or panel object. With…
Krasnars
  • 350
  • 2
  • 17
7
votes
1 answer

Can I test autocorrelation from the generalized least squares model?

I am trying to use a generalized least square model (gls in R) on my panel data to deal with autocorrelation problem. I do not want to have any lags for any variables. I am trying to use Durbin-Watson test (dwtest in R) to check the…
Eric
  • 528
  • 1
  • 8
  • 26
7
votes
2 answers

linearmodels panelOLS: Regression output with stars

I'm using the linearmodels package to estimate a Panel-OLS. As an example see: import numpy as np from statsmodels.datasets import grunfeld data = grunfeld.load_pandas().data data.year = data.year.astype(np.int64) # MultiIndex, entity - time data =…
Daniel
  • 304
  • 2
  • 12
6
votes
1 answer

Long/wide data to wide/long

I have a data frame that look as follow: import pandas as pd d = {'decil': ['1. decil','1. decil','2. decil','2. decil','3. decil','3. decil'], 'kommune': ['AA','BB','AA','BB','AA','BB'],'2010':[44,25,242,423,845,962], …
A.joh
  • 89
  • 1
  • 1
  • 10
6
votes
2 answers

error in plm regression

colleagues! I have panel data: Company year Beta NI Sales Export Hedge FL QR AT Foreign 1 1 2010 -2.2052800 293000 1881000 78.6816 0 23.5158 1.289 0.6554 3000 2 1 2011 -2.2536069 316000 2647000…
Ruslan Sayakhov
  • 169
  • 1
  • 2
  • 7
6
votes
2 answers

Panel data in Keras LSTM

I am looking at panel data, which is structured like this: D = \{(x^{(k)}_{t},y^{(k)}_{t})\,|\, k=1,\dots,N\, , t=t_0,\dots,t_k \}_{k=1}^{N} where x^{(k)} denotes the k'th sequence, x^{(k)}_{t} denotes the k'th sequences value at time t ,…
Math_kv
  • 309
  • 3
  • 10
6
votes
7 answers

How do I Difference Panel Data in R

I am wondering if there is any easy R commands or packages that will all allow me to easily add variables to data.frames which are the "difference" or change of over time of those variables. If my data looked like this: set.seed(1) MyData <-…
Francis Smart
  • 3,875
  • 6
  • 32
  • 58
6
votes
2 answers

Panel data regression: Robust standard errors

my problem is this: I get NA where I should get some values in the computation of robust standard errors. I am trying to do a fixed effect panel regression with cluster-robust standard errors. For this, I follow Arai (2011) who on p. 3 follows…
Jan
  • 85
  • 1
  • 6
5
votes
3 answers

Create a time to and time after event variables

I am working on panel data that looks like this: d <- data.frame(id = c("a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "c", "c", "c", "c", "c"), time = c(1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5), iz = c(0,1, 1,…
Niklas
  • 53
  • 4
5
votes
2 answers

formatting data for fixed-effect regression (paneldata) in python?

I have a large data set i need to conduct time-series analysis on. The data is currently in excel formated as…
5
votes
2 answers

Merge Panel data to get balanced panel data

I have several data frames in panel data form. Now I want to merge these panel data frames into one panel data. These data frames have common and different between them. I illustrate as follows: df1: Month variable Beta1 Beta2 Beta3 Beta4…
user5975038
5
votes
1 answer

Calculating within, between or overall R-square in R

I'm migrating from Stata to R (plm package) in order to do panel model econometrics. In Stata, panel models such as random effects usually report the within, between and overall R-squared. I have found that the reported R-squared in the plm Random…
user3507584
  • 3,246
  • 5
  • 42
  • 66
5
votes
2 answers

R: Plotting panel model predictions using plm & pglm

I've created two regression models using a linear panel model with plm, and a generalized panel model using poisson with the pglm package. library(plm); library(pglm) data(Unions) # from pglm-package punions <- pdata.frame(Unions, c("id",…
ageil
  • 171
  • 1
  • 3
  • 16
5
votes
3 answers

Panel data with binary dependent variable in R

Is it possible to do regressions in R using a panel data set with a binary dependent variable? I am familiar with using glm for logit and probit and plm for panel data, but am not sure how to combine the two. Are there any existing code…
Abiel
  • 5,251
  • 9
  • 54
  • 74
1
2
3
56 57