createAdj: Creates an adjacency matrix

Description Usage Arguments Details Value Author(s) Examples

View source: R/createAdj.R

Description

Creates an adjacency matrix in a form suitable for using in BRugs or WinBUGS.

Usage

1
createAdj(matrix, filename='Adj.txt', suffix=NULL)

Arguments

matrix

square matrix with 1's for neighbours and NA's for non-neighbours.

filename

filename that the adjacency matrix file will be written to (default=‘Adj.txt’).

suffix

string to be appended to ‘num’, ‘adj’ and ‘weights’ object names

Details

Adjacency matrices are used by conditional autoregressive (CAR) models to smooth estimates according to some neighbourhood map. The basic idea is that neighbouring areas have more in common than non-neighbouring areas and so will be positively correlated.

As well as correlations in space it is possible to use CAR models to model similarities in time.

In this case the matrix represents those time points that we wish to assume to be correlated.

Value

Creates a text file named filename that contains the total number of neighbours (num), the index number of the adjacent neighbours (adj) and the weights (weights).

Author(s)

Adrian Barnett a.barnett<at>qut.edu.au

Examples

1
2
3
4
# Nearest neighbour matrix for 5 time points
x = c(NA,1,NA,NA,NA)
(V = toeplitz(x))
createAdj(V)

season documentation built on May 2, 2019, 5:22 p.m.