基于R语言的重叠事件窗口SUR模型同步估计技术问询
Hey there! Let's get your SUR model set up correctly to account for the overlapping event windows between the Netherlands and Cyprus datasets. The issue with your current code is that you're fitting two separate SUR models—this doesn't capture the cross-equation error correlation that's the whole point of using SUR when windows overlap. Here's how to fix it step by step:
Step 1: Combine Your Datasets with a Country Identifier
First, we need to merge both panels into one dataset, adding a marker to distinguish observations from each country. This lets us define separate equations for each country within the same SUR system.
library("systemfit") library("plm") # Load and prep Netherlands data nederland <- read.table("https://pastebin.com/raw.php?i=93qFnEir", sep=";", header=TRUE) nederland$country <- "NL" # Add unique country tag nedpanel <- pdata.frame(nederland, c("id", "t")) # Load and prep Cyprus data cyprus <- read.table("https://pastebin.com/raw.php?i=93qFnEir", sep=";", header=TRUE) cyprus$country <- "CY" # Add unique country tag cyppanel <- pdata.frame(cyprus, c("id", "t")) # Combine both panels into a single dataset combined_panel <- rbind(nedpanel, cyppanel)
Step 2: Define a Single SUR System with Two Equations
Next, we'll create two equations (one for each country) and estimate them simultaneously using systemfit. We use conditional filtering (| country == "NL") to tell the model which observations belong to each equation.
# Define separate equations for each country eq_netherlands <- returns ~ Price + Pre + Event + Post | country == "NL" eq_cyprus <- returns ~ Price + Pre + Event + Post | country == "CY" # Estimate the combined SUR model (captures cross-equation error correlation) combined_sur <- systemfit( list(Netherlands = eq_netherlands, Cyprus = eq_cyprus), method = "SUR", data = combined_panel ) # Inspect the results summary(combined_sur)
Why This Works
- Captures Error Correlation: By estimating both equations in a single system,
systemfitcalculates the covariance between the error terms of the Netherlands and Cyprus equations. This gives you correct standard errors, which your separate model runs were missing. - Maintains Equation Specificity: The conditional filters ensure each equation only uses the relevant country's data, so you're still estimating the effect of
Event,Pre,Post, andPriceseparately for each country—just with the benefit of SUR's efficiency gains.
If you have differences in the individual or time dimensions between the two datasets, this approach still works because the conditional filtering automatically maps each equation to its correct observations.
内容的提问来源于stack exchange,提问作者Dave13

