I was running some SDM (and SAR for robustness) regressions in R using the SPLM package. To correctly interpret coefficients I need to calculate direct/indirect impacts which the SPLM package can no longer do due to changes in the SPDEP package which it is built off of. XSMLE in Stata can also run SDM regressions and it can also still calculate impacts so I have attempted to replicate my regressions from R in Stata. While I expected them to not be identical due to the software switch, they are currently so wildly different (huge differences in size, sign, and significance of coefficient estimates) that I clearly have missed something, but I have been unable to identify what it is.
I have looked at the weight matrices from both Stata and R and they appear identical (compared their GAL text files side by side). According to documentation both SPLM and XSMLE should be spatially lagging variables in the same manner (multiplying the Nx1 variable vector by the NxN weight matrix) and both should be using maximum likelihood (ML) estimation for their regressions.
In R I was effectively running:
Where 'lag = T, spatial.error = "none"' and the spatially lagged explanatory variables specifies a SDM model. And 'model = "within", effect = "twoways"' should specify a fixed effects model with both time and individual fixed effects.
In Stata I have attempted to replicate this with:
Where 'model(sdm)' tells Stata to spatially lag the explanatory variables and control for them along with spatially lagging the dependent variable and not the errors to make it SDM. 'fe type(both)' should specify a fixed effects model with two-way fixed effects. 'eff vcee(sim, nsim(99))' should only relate to the calculation of direct/indirect effects and not impact the coefficient estimates.
I am hoping someone with more experience with XSMLE can identify something I have missed. Or perhaps someone who has experience replicating R results in Stata could provide some tips. I am sure that I need to provide more details but I wanted to avoid writing too much and including inconsequential information and can happily add whatever information would help.
I have looked at the weight matrices from both Stata and R and they appear identical (compared their GAL text files side by side). According to documentation both SPLM and XSMLE should be spatially lagging variables in the same manner (multiplying the Nx1 variable vector by the NxN weight matrix) and both should be using maximum likelihood (ML) estimation for their regressions.
In R I was effectively running:
Code:
Model <- DepVar ~ ListOfExplanatoryVars + ListOfSpatiallyLaggedExplanatoryVars reg <- spml(Model, DataSet, index = NULL, listw = WeightMatrix, lag = T, spatial.error = "none", model = "within", effect = "twoways", zero.policy = TRUE)
In Stata I have attempted to replicate this with:
Code:
xsmle DepVar ListOfExplanatoryVars, wmat(WeightMatrix) model(SDM) fe type(both) eff vcee(sim, nsim(99))
I am hoping someone with more experience with XSMLE can identify something I have missed. Or perhaps someone who has experience replicating R results in Stata could provide some tips. I am sure that I need to provide more details but I wanted to avoid writing too much and including inconsequential information and can happily add whatever information would help.
Comment