Dear readers,
I have a balanced panel data on 41 countries over 39 years. I merged the data with a shapefile and all worked as expected. I also created spatial weighting matrices successfully. However, when I use these matrices in the panel regression estimation using xsmle I get an error indicating that the weighting matrices are not valid. I would greatly appreciate your help.

Blow are summaries from my code.

Code:
spset
      Sp dataset: fulldata.dta
Linked shapefile: Africa_shp.dta
            Data: Panel
 Spatial-unit ID: _ID (equal to iso)
         Time ID: year (see xtset)
     Coordinates: _CY, _CX (latitude-and-longitude, miles)
I then filtered the data to one year so that I can create spatial weighting matrices, as follows:


Code:
​​​​​​preserve
keep if year == 2000
spmatrix create contiguity Wc // contiguity
spmatrix create idistance Widist // inverse distance
restore
Code:
. spmatrix summarize Wc 

Weighting matrix Wc
---------------------------------------
           Type |           contiguity
  Normalization |             spectral
      Dimension |              41 x 41
Elements        |
   minimum      |                    0
   minimum > 0  |             .1856635
   mean         |             .0189971
   max          |             .1856635
Neighbors       |
   minimum      |                    1
   mean         |             4.195122
   maximum      |                    9
---------------------------------------

. spmatrix summarize Widist

Weighting matrix Widist
---------------------------------------
           Type |            idistance
  Normalization |             spectral
      Dimension |              41 x 41
Elements        |
   minimum      |                    0
   minimum > 0  |             .0062247
   mean         |             .0224497
   max          |             .3301543
---------------------------------------
However, when I tried running models using
Code:
xsmle y x1 x2 x3 x4 , dlag(3) wmat(Wc) model(sdm) fe dlag(3) effects nolog
xsmle y x1 x2 x3 x4 , dlag(3) wmat(Widist) model(sdm) fe dlag(3) effects nolog
I got the following errors:
Code:
Wc is not a valid spmat object
and
Code:
 Widist is not a valid spmat object