Additional supporting functions for random Markov fields

Share:

Description

This set of functions are useful to get information and to plot maps.

Usage

1
2
3
4
5
6
draw.polys(polys, object = NULL, scheme = NULL, 
           swapcolors = FALSE, n.col = 100, ...)
polys2nb(polys)                 
nb2prec(neighbour,x,area=NULL)
polys2polys(object, neighbour.nb)
nb2nb(neighbour.nb)

Arguments

polys

an object containing the polygon information for the area

object

are either the values to plot in the draw.polys() function or a polygons information for a shape file for function polys2polys

scheme

scheme of colours to use, it can be "heat", "rainbow", "terrain", "topo", "cm" or any colour

swapcolors

to reverse the colours, it just work for "heat", "rainbow", "terrain", "topo", "cm" options

n.col

range for the colours

neighbour.nb

neighbour information for a shape file for function nb2nb

neighbour

the neighbour information, and if the neighbour is from S4 shape file than use nb2nb to transfer it to the appropriate neighbour for MRF(), MRFA(), mrf() and mrfa().

x

the factor defining the areas

area

all possible areas involved

...

for extra options

Details

draw.polys() plots the fitted values of fitted MRF object.

polys2nb() gets the neighbour information from the polygons.

nb2prec() creates the precision matrix from the neighbour information.

polys2polys() transforms a shape file polygons (S4 object) to the polygons required form for the functions MRF() and MRFA().

nb2nb() transforms from a shape file neighbour (S4 object) to the neighbour required form for functions MRF().

Value

The draw.polys() produces a plot while the rest of the functions produce required object for fitting or plotting.

Author(s)

Fernanda De Bastiani, Mikis Stasinopoulos, Robert Rigby and Vlasios Voudouris

Maintainer: Fernanda <fernandadebastiani@gmail.com>

References

Rigby, R. A. and Stasinopoulos D. M. (2005). Generalized additive models for location, scale and shape,(with discussion), Appl. Statist., 54, part 3, pp 507-554.

Rue and Held (2005) Gaussian markov random fields: theory and applications, Chapman & Hall, USA.

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use the GAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (see also http://www.gamlss.org/).

Stasinopoulos D. M. Rigby R.A. (2007) Generalized additive models for location scale and shape (GAMLSS) in R. Journal of Statistical Software, Vol. 23, Issue 7, Dec 2007, http://www.jstatsoft.org/v23/i07.

See Also

MRF, MRFA

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# bringing required libraries
library(spdep)
library(maptools)
# reading the shape file 
bh <- readShapePoly(system.file("etc/shapes/bhicv.shp",package="spdep")[1])
# pick up part of the data
BhData <- data.frame(scale(bh@data[,5:8]))  
# getting the neiboiurhood and the polygons using the spdep functions 
bh.nb=poly2nb(bh)
bh.polys=bh@polygons
# now getting the information for the S4 object to required format
newpolys <- polys2polys(bh.polys,bh.nb)
newnb   <- nb2nb(bh.nb)
# drawing the map 
draw.polys(newpolys[[1]])
# now get the precition matrix
Prec <- nb2prec(newnb, x=as.factor(row.names(BhData)), area=as.factor(row.names(BhData)))