# How to estimate a spatial weight matrix empirically?

Let $y$ be an n-vector of observations on the dependent variable and $X$ be the $n \times k$ design matrix with observations for $n$ units on $k$ variables. I aim to estimate a time-series cross-sectional spatial autoregressive regression model of the following form:

$$Y_t = X_t \beta + \rho W_{t-1} Y_{t-1} + \epsilon_t$$

where $W_t$ denotes an $n \times n$ dynamic spatial weights matrix with typical elements $w_{ij}$ greater than zero if units $i$ and $j$ are connected and the estimated parameter $\rho$ describes the strength and direction of spatial autocorrelation.

Now, my question concerns the spatial weight matrix W that, in most applications, is not estimated empirically but specified a priori and somewhat arbitrarily. I would like to estimate the connectivity between units $i$ and $j$, countries in my case, empirically based on a number of continuous indicators such as dyadic trade, geographic proximity, etc.

Is there any way to first obtain estimates of dyadic connectivity through a latent variable model (e.g. some variant of factor analysis) and then use these estimates as part of the spatial regression model? Basically, I am looking for a way to specify $W$ through empirics rather than by assumption. Thank you very much in advance for any suggestions!