`lnam`

is used to fit linear network autocorrelation models. These include standard OLS as a special case, although `lm`

is to be preferred for such analyses.

```
lnam(y, x = NULL, W1 = NULL, W2 = NULL, theta.seed = NULL,
null.model = c("meanstd", "mean", "std", "none"), method = "BFGS",
control = list(), tol=1e-10)
```

y

a vector of responses.

x

a vector or matrix of covariates; if the latter, each column should contain a single covariate.

W1

one or more (possibly valued) graphs on the elements of `y`

.

W2

one or more (possibly valued) graphs on the elements of `y`

.

theta.seed

an optional seed value for the parameter vector estimation process.

null.model

the null model to be fit; must be one of `"meanstd"`

, `"mean"`

, `"std"`

, or `"none"`

.

method

method to be used with `optim`

.

control

optional control parameters for `optim`

.

tol

convergence tolerance for the MLE (expressed as change in deviance).

An object of class `"lnam"`

containing the following elements:

the response vector used.

if supplied, the coefficient matrix.

if supplied, the W1 array.

if supplied, the W2 array.

a code indicating the model terms fit.

the estimated Fisher information matrix for the fitted model.

the estimated asymptotic covariance matrix for the model parameters.

a string indicating the null model fit.

the log-likelihood of y under the null model.

the residual degrees of freedom under the null model.

the model degrees of freedom under the null model.

parameter estimates for the null model.

the log-likelihood of y under the fitted model.

the model degrees of freedom.

the residual degrees of freedom.

the total degrees of freedom.

if applicable, the MLE for rho1.

if applicable, the asymptotic standard error for rho1.

if applicable, the MLE for rho2.

if applicable, the asymptotic standard error for rho2.

the MLE for sigma.

the standard error for sigma

if applicable, the MLE for beta.

if applicable, the asymptotic standard errors for beta.

the fitted mean values.

the residuals (response minus fitted); note that these correspond to \(\hat{e}\) in the model equation, not \(\hat{\nu}\).

the estimated disturbances, i.e., \(\hat{\nu}\).

the matched call.

`lnam`

fits the linear network autocorrelation model given by

$$y = W_1 y + X \beta + e, \quad e = W_2 e + \nu$$

where \(y\) is a vector of responses, \(X\) is a covariate matrix, \(\nu \sim N(0,\sigma^2)\),

$$W_1 = \sum_{i=1}^p \rho_{1i} W_{1i}, \quad W_2 = \sum_{i=1}^q \rho_{2i} W_{2i},$$

and \(W_{1i}\), \(W_{2i}\) are (possibly valued) adjacency matrices.

Intuitively, \(\rho_1\) is a vector of ``AR''-like parameters (parameterizing the autoregression of each \(y\) value on its neighbors in the graphs of \(W_1\)) while \(\rho_2\) is a vector of ``MA''-like parameters (parameterizing the autocorrelation of each *disturbance* in \(y\) on its neighbors in the graphs of \(W_2\)). In general, the two models are distinct, and either or both effects may be selected by including the appropriate matrix arguments.

Model parameters are estimated by maximum likelihood, and asymptotic standard errors are provided as well; all of the above (and more) can be obtained by means of the appropriate `print`

and `summary`

methods. A plotting method is also provided, which supplies fit basic diagnostics for the estimated model. For purposes of comparison, fits may be evaluated against one of four null models:

`meanstd`

: mean and standard deviation estimated (default).`mean`

: mean estimated; standard deviation assumed equal to 1.`std`

: standard deviation estimated; mean assumed equal to 0.`none`

: no parameters estimated; data assumed to be drawn from a standard normal density.

The default setting should be appropriate for the vast majority of cases, although the others may have use when fitting ``pure'' autoregressive models (e.g., without covariates). Although a major use of the `lnam`

is in controlling for network autocorrelation within a regression context, the model is subtle and has a variety of uses. (See the references below for suggestions.)

Leenders, T.Th.A.J. (2002) ``Modeling Social Influence Through Network Autocorrelation: Constructing the Weight Matrix'' *Social Networks*, 24(1), 21-47.

Anselin, L. (1988) *Spatial Econometrics: Methods and Models.* Norwell, MA: Kluwer.

```
# NOT RUN {
#Construct a simple, random example:
w1<-rgraph(100) #Draw the AR matrix
w2<-rgraph(100) #Draw the MA matrix
x<-matrix(rnorm(100*5),100,5) #Draw some covariates
r1<-0.2 #Set the model parameters
r2<-0.1
sigma<-0.1
beta<-rnorm(5)
#Assemble y from its components:
nu<-rnorm(100,0,sigma) #Draw the disturbances
e<-qr.solve(diag(100)-r2*w2,nu) #Draw the effective errors
y<-qr.solve(diag(100)-r1*w1,x%*%beta+e) #Compute y
#Now, fit the autocorrelation model:
fit<-lnam(y,x,w1,w2)
summary(fit)
plot(fit)
# }
```

Run the code above in your browser using DataLab