852 questions
1
vote
0
answers
44
views
Trouble using "ifelse" or "case_when" to create indicator variable in for panel data [duplicate]
I am trying to create a indicator variable for panel data flagging "on/before" a certain year and "after". Trying both "ifelse" and "case_when" approaches, I do ...
0
votes
0
answers
27
views
Cipstest in plm library: Error in xy.coords(x, y, setLab = FALSE) : 'x' and 'y' lengths differ
Here is a dataset I want to run Pesaran's panel unit root test using the cipstest function in the plm library.
It keeps giving me the error "x and y lengths differ", and I cannot sort this ...
2
votes
1
answer
62
views
Issue with predict.plm() when using lag() inside the regression
I've recently encountered a problem with predict() function for plm regression that uses AR(1) term in form of lag().
Here is an toy example: 3 countries, 3 periods, current population as a function a ...
1
vote
1
answer
37
views
How to convert a worksheet in a panel in R? [duplicate]
Below is a small sample of my database.
As you can see, there two units (3100104 and 3100203) and a variable X that is numerical, assuming values in 2010 and 2011.
The problem is that I need to ...
0
votes
1
answer
63
views
How to transform 'panel data' structure into a data structure suitable for Cox Regression?
I made up some dummy data that has a very similar structure as our internal data I cannot share.
I would like to know how to prepare it for the Cox Regression.
Could you help me to pre-process the ...
0
votes
1
answer
62
views
Set fixed effects at a different variable than a panel index variable
I am trying to run a plm panel fixed effects model. The panel index runs at the county-year level. The challenge? I want to run fixed effects at the (higher order) state level. I can easily program ...
0
votes
0
answers
30
views
Seemingly wrong output for a Fixed Effect Poisson Regression using pglm in R
I want to run a fixed effect regression with net migration being the response and gini index a predictor. I add some control variables. The data is from WDI.
Because the response in the data set has ...
0
votes
2
answers
61
views
Total percent change in a column in R?
I have a panel dataset in R that documents the percent change in population for cities over several years. A simplified version looks like this:
city_pop<-tibble(city=c("NYC", "NYC&...
1
vote
1
answer
172
views
Missing SRI hash version in python environment
I'm trying to use Panel for the first time in Jupyter Notebook. I've pip installed it and trying to just run in my python environment:
import panel as pn
however I get this error: ValueError: Missing ...
1
vote
0
answers
40
views
How to generate a bootstrap standard error, t statistics and p value for a user written dynamic panel quantile regression
rm(list=ls())
library(quantreg)
library(SparseM)
library(stats)
rq.fit.panel <- function(X,y,s,w=c(1),taus=0.30,lambda = 0){
# prototype function for panel data fitting of QR models
# the ...
1
vote
1
answer
45
views
Stata: Number of overlapping dates in date range (non-unique values)
This question is based on a previous answer Stata: Number of overlapping days within multiple date ranges that has (mostly) helped me. I want to calculate the number of overlapping days within ...
1
vote
2
answers
90
views
Panel data from Excel transformation
I have data from the WIND terminal with the data structured in rows (even time series information)
For example:
Ticker Company Name NetProfitGrowth2009 NetProfitGrowth2010
I believe in order to ...
0
votes
1
answer
656
views
HAC standard errors in R using plm package?
I want to estimate a fixed effects model (with both country- and year fixed effects) and ADDITIONALLY apply HAC standard errors. Although I didn't get any error message after running the following ...
3
votes
0
answers
431
views
How to include time and unit fixed effects in a mediation model using R?
I'm trying to get the indirect effects of the mediation variables m1, m2, and m3 in my dependent variable "y". But also considering the effect of the independent variable "iv" on ...
1
vote
1
answer
132
views
How to assign the maximum value of the other variable to a variable by group?
ID Time Condition Seq Want_temp Want_final_v1
A 1 yes 0 0 0
A 2 yes 0 . 1
A 3 no 1 . .
A ...
1
vote
2
answers
67
views
Regression with Panel Data (Wide)?
I am trying to run the following model of GDP on population:
GDP_(i,t) = alpha + beta*Population_(i,t) + epsilon
Here, each variable is indexed by time (t) and country (i).
I have a panel dataset df1 ...
1
vote
1
answer
81
views
Two-way fixed effect estimation via `plm` fails with an error message (but works via `lm`)
I am trying to run a two-way fixed-effects panel regression using plm in R. First, I randomly generate some data. Then I create time and firm indices (two-way indexing as usual in a panel dataset) and ...
0
votes
1
answer
121
views
Fixed effect panel regression gives coefficients for each year
I am trying to use Entity fixed panel regression for my data set. I have cross sectional data for each county in the US and for 1971 to 2020 (yearly). I have two indices: STCTID which is county ID and ...
0
votes
0
answers
125
views
Predict Panel Data Model values with a LSTM network
I want to make predictions of how many mail postards are sent daily in every post office in my city. The problem seems easy, but I want to predict how many postcards are sent in each office and what ...
1
vote
1
answer
147
views
PLM package: Difference between PMG and PCCE function
What is the difference of pmg and pcce function in package plm? Details of both is almost same in the description. I wanted to perform mg, pmg and CCE mg test on panel data using plm function. I ...
0
votes
2
answers
193
views
Creating T-1 variable | R [duplicate]
I would like to create a new variable sales.T.minus.1 which will present the value of sales from year - 1. I created a replicable example below:
library(plm)
library(dplyr)
data <- pdata....
0
votes
0
answers
157
views
How to do interrupted time series analysis using R's plm?
I am trying to model the following interrupted time series model:
y = b0 + b1*time + b2*event + b3*time_since_event
The data, however, is nested inside users (id). Currently, I have the following ...
0
votes
1
answer
65
views
rollapply a function across different columns in a panel dataset
I am trying to calculate the idiosyncratic skewness for different funds in a panel data. Basically, I hope to regress the daily returns of a fund on the market return and the squared market return to ...
-1
votes
1
answer
242
views
How to do hyper-parameter tuning with panel data in sklearn framework?
Imagine we have multiple time-series observations for multiple entities, and we want to perform hyper-parameter tuning on a single model, splitting the data in a time-series cross-validation fashion.
...
0
votes
0
answers
64
views
group_by (dplyr, R) not working with unit ID and time--aggregating by unit ID only
I have two panel data sets that are mergeable. However, I have to create bins of time as both data sets are highly imbalanced and have highly variable measurement occasions.
One approach is the ...
0
votes
1
answer
51
views
Identifying crisis episodes
New R user here.
I have a relatively large panel of countries, and I want to identify recession episodes.
labor_pivoted_crisis=labor_pivoted%>%
group_by(country)%>%
mutate(crisis=ifelse(...
-1
votes
1
answer
48
views
Create a year variable to establish a panel variable-
I have 3 variables in Stata that I want to make into a panel variable, f4hi. Currently, they are called f4hi97, f4hi98, and f4hi99. I want to pull the last two digits from these to create a separate ...
0
votes
1
answer
720
views
Running a spatial durbin model (SDM) for a panel data
I'm trying to run a Spatial Durbin Model for a spatial panel data. My idea is to run the dependent variable y over my independent variables x1 and x2. I've tried so many options but all of them give ...
1
vote
2
answers
79
views
Creating dyad-pair averages in R
I want to create a pair-wise average of price of commodities produced by countries. My data looks like this
df <- data.frame(country = c("US; UK; FI", "CN; IT; US; GR", "...
0
votes
0
answers
50
views
Bias estimation of the lagged variable coefficient
We use a data generating process to create a panel data set and now we want to include a lagged variable and see the effect of the bias for different time periods. The data for the first year of the ...
0
votes
1
answer
159
views
How can I import entity_effects and time_effects from PanelOLS?
When I run the code:
from linearmodels.panel import PanelOLS, PooledOLS
from linearmodels.panel import EntityEffects, TimeEffects
I get the error:
ImportError: cannot import name 'EntityEffects' from ...
0
votes
0
answers
94
views
Error message in R during export of a panel dataset to a CSV file
I am currently trying to export a panel dataset in R to a CSV file. When exporting I receive the following error message in R:
Error in `is.data.frame()`:
! Can't recycle `value` (size 6) to size 4.
...
0
votes
0
answers
42
views
How do I write a code that identifies coworker flows between firms?
I am struggling to write a code that first identifies coworker flows between two firms, and secondly creates a variable for mergers if the overlap is greater than 50%. Unfortunately, I only have firm, ...
2
votes
0
answers
132
views
Why is `fixest` not allowing for lagged variables?
I am dealing with fixed-effects regressions in R using the fixest package. Let's suppose I want to estimate something super simple as
$$
Y_{i, t} = \alpha + \beta X_{i, t-1} + u_{i, t}
$$
So I want to ...
1
vote
1
answer
696
views
Reporting heteroscedasticity-robust standard errors in modelsummary for panel data (plm)
I encounter a problem with the reporting of heteroscedasticity-robust standard errors for a panel data regression (plm) in the output with modelsummary. For a simple linear regression the reporting ...
0
votes
1
answer
95
views
Linear Programming in Mata with panel data - looping over individuals, specifying objective function
I try to use linear programming in Mata.
I would like to assign an education category (z,s,v = low, middle, high) to each individual according to probabilities obtained previously by odered probit. I ...
0
votes
0
answers
144
views
Transforming monthly panel data into quarterly based on multiple criteria [duplicate]
I have a panel dataset with countries, date and two columns with other data (inflation rate and payments from a specific program). What I want is to aggregate the data from monthly into quarterly data ...
0
votes
0
answers
68
views
cannot allocate memory in static R regression
I'm trying to run a regression in R and I want to control the fipsmerg variable by factors but R gives me a memory error.
input:
myprobit <- glm(a_imt~a_imt_1+totpop+reltrad_1+reltrad_2+reltrad_3+...
0
votes
1
answer
29
views
Balanced Panel -n and T are mixed up
I have a fix effects model like this:
Indeksy <- updata.frame(PiS, index = c("Rok","Powiat")))
fixed_effects_model_05_07 <- plm(Logarytm_Wynik_Wyborczy_05_07 ~ ...
0
votes
1
answer
95
views
Rolling mean and median for panel data in R
I have a panel data:
Date
ID
Value
Mon
A
10
Tue
A
11
Wed
A
15
Thu
A
12
Mon
B
11
Tue
B
13
Wed
B
12
Thu
B
13
Mon
C
14
Tue
C
10
Wed
C
13
Thu
C
12
I would like to create a new column that whihc is the ...
0
votes
0
answers
124
views
Panel data in Python set index
I´m spending a lot of time trying to set my panel data.
Everytime that I run the following command df.set_index(['id', 'datas'] I have the message that "None of ['id', 'datas'] are in the ...
0
votes
0
answers
70
views
How can I merge different datasets to create a panel dataset in R?
I have a dataset that contains four different countries and measures child labor and other characteristics. I have one dataset that already contains rounds 2, 3, and 4 (OC234) merged together (thanks ...
0
votes
0
answers
39
views
Joining two tables in R provides wrong output
I am trying to create panel data set by joining Table 1 and Table 2
Table 1
Table 2
The output I would like to receive is that I will have 4 columns:
Powiat | Rok | Liczba bezrobotnych | Srednie ...
0
votes
0
answers
252
views
Direct and indirect effects of spatial panel durbin model
I'm asking about the estimation of direct, indirect, and total effects of spatial durbin panel data modeling. As far as I know, there is no direct package of doing the estimations. So I generate the ...
0
votes
1
answer
71
views
Fill down a range of rows in R [closed]
I have a panel dataset in R, which includes observations per group over time (month). The following dataframe is a snapshot of the complete dataframe:
df <- data.frame(group = c(1, 1, 1, 1, 1, 1, 1,...
0
votes
0
answers
499
views
Panel data cointegration test: Package pco R, how to interpret output from pedroni99 function?
I have a panel dataset and I want to test cointegration between 2 variables. I cleaned the missing values and set my data frame as required but I don't know how to interpret the results/ outcome from ...
0
votes
1
answer
110
views
Data manipulation in python for an excel file
I have to conduct a panel analysis for Euro area countries. I have an excel dataset for all the 20 countries in the Euro Area for the years starting from 1995 to 2022 for the HCPI, the final aggregate ...
0
votes
3
answers
700
views
Panel Data Fixed effects regression in R using PLM package with multiple obs/yr
I have a panel data:
Panel Data set - gravity model international trade
My R code:
#importing dataset
df <- read_excel("DataSet_Final.xlsx",
col_types = c(&...
0
votes
0
answers
93
views
Better estimate three level panel data with plm() or lmer()?
I have a question about an analysis I want to perform with panel data with three levels.
Am i correct if because it's panel data, plm() (from package plm) would be more appropriate, however it does ...
0
votes
1
answer
245
views
How to conduct a panel regression on this data in R?
In R I have a table "education":
enter image description here
(my full table is much larger, it has more countries, indicators and years
I need to use panel regression in R to verify the ...