# Additional supporting functions for random Markov fields

### 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 |

`scheme` |
scheme of colours to use, it can be |

`swapcolors` |
to reverse the colours, it just work for |

`n.col` |
range for the colours |

`neighbour.nb` |
neighbour information for a shape file for function |

`neighbour` |
the neighbour information, and if the neighbour is from S4 shape file than use |

`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)))
``` |