Dear Statalists,
I am trying to run the Anselin-Kelejian test for assessing spatial autocorrelation in my dataset. I have already generated a spatial matrix through spmat command, and I was able to save it as a .dta file and use it to run the Moran's I test through the spatgsa command. However, I am not sure I fully get the functioning of the anketest command, which I am trying to use to run the autocorrelation testl. I understand it is a post-estimation command, so I run a simple ols to do the test, but the command does not seem to find the matrix. I am not very familiar with working with matrices on Stata, but I think that the matrix is in the programme, and it is anyway stored as a .dta file in my working directory.
Can anybody help me to get the command to find the matrix? Here I attach the series of commands and part of the output that I run from the formation of the matrix till the error messages that the system reports after using ANKETEST.
Thank you!
Chiara
I am trying to run the Anselin-Kelejian test for assessing spatial autocorrelation in my dataset. I have already generated a spatial matrix through spmat command, and I was able to save it as a .dta file and use it to run the Moran's I test through the spatgsa command. However, I am not sure I fully get the functioning of the anketest command, which I am trying to use to run the autocorrelation testl. I understand it is a post-estimation command, so I run a simple ols to do the test, but the command does not seem to find the matrix. I am not very familiar with working with matrices on Stata, but I think that the matrix is in the programme, and it is anyway stored as a .dta file in my working directory.
Can anybody help me to get the command to find the matrix? Here I attach the series of commands and part of the output that I run from the formation of the matrix till the error messages that the system reports after using ANKETEST.
Thank you!
Chiara
Code:
*I build the matrix spmat contiguity Wmm using gdxy, id(id) replace normalize(minmax) * I save it as a .dta file spmat export Wmm using "Wmm.txt", noid replace insheet using "Wmm.txt", delim(" ") clear drop in 1 save "Wmm.dta", replace *I use it to run the Moran's I test.. . use "gddatabase.dta", clear spatwmat using "Wmm.dta", name(Ws) spatgsa ln_output, weights(Ws) moran *... and it works Moran's I -------------------------------------------------------------- Variables | I E(I) sd(I) z p-value* --------------------+----------------------------------------- ln_output | 0.557 -0.012 0.077 7.346 0.000 -------------------------------------------------------------- *1-tail test *I run the regression: reg ln_output dummy_zones developmentzones nst ln_inv_t3 ln_fdi_t3 ln_work prd coast urban, robust (output omitted) *and here is the problem with the ANKETEST anketest, wname(Wmm) wfrom(Stata) model(ols) (11 missing values generated) Matrix Wmm not found r(601); anketest, wname(Wmm) wfrom(Mata) model(ols) (11 missing values generated)
Comment