Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/extraFunctions.R

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

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

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

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

.

The `draw.polys()`

produces a plot while the rest of the functions produce required object for fitting or plotting.

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

Maintainer: Fernanda <[email protected]>

Stasinopoulos, D. M., Rigby, R. A., Heller, G. Z., Voudouris, V. and De Bastiani, F. (2017) *Flexible Regression and Smoothing: Using GAMLSS in R*. Chapman and Hall, Boca Raton.

De Bastiani, F. Rigby, R. A., Stasinopoulos, D. M., Cysneiros, A. H. M. A. and Uribe-Opazo, M. A. (2016) Gaussian Markov random eld spatial models in GAMLSS. *Journal of Applied Statistics*, pp 1-19.

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.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ```
# bringing the required libraries
library(spdep)
library(maptools)
# reading the shape file from package spdep
bh <- readShapePoly(system.file("etc/shapes/bhicv.shp",
package="spdep")[1])
# pick up parts of the data and scale them
BhData <- data.frame(scale(bh@data[,5:8]))
# getting the neighbourhood and the polygons using the package
# spdep functions
bh.nb <- poly2nb(bh) # neighbourhood
bh.polys <- bh@polygons # polygons
# now getting the information for the S4 object to required format
# from object S4 to object S3
newpolys <- polys2polys(bh.polys,bh.nb)
newnb <- nb2nb(bh.nb)
# drawing the map
draw.polys(newpolys[[1]])
# plotting one of the variables in BhData
poo <-BhData$HLCI
names(poo) <- row.names(BhData)
draw.polys(newpolys[[1]], poo)
# now get the precision matrix
Prec <- nb2prec(newnb, x=as.factor(row.names(BhData)),
area=as.factor(row.names(BhData)))
``` |

```
Loading required package: gamlss.dist
Loading required package: MASS
Loading required package: gamlss
Loading required package: splines
Loading required package: gamlss.data
Loading required package: nlme
Loading required package: parallel
********** GAMLSS Version 5.0-2 **********
For more on GAMLSS look at http://www.gamlss.org/
Type gamlssNews() to see new features/changes/bug fixes.
Loading required package: gamlss.add
Loading required package: mgcv
This is mgcv 1.8-20. For overview type 'help("mgcv-package")'.
Loading required package: nnet
Attaching package: 'nnet'
The following object is masked from 'package:mgcv':
multinom
Loading required package: rpart
Loading required package: spam
Loading required package: dotCall64
Loading required package: grid
Spam version 2.1-1 (2017-07-02) is loaded.
Type 'help( Spam)' or 'demo( spam)' for a short introduction
and overview of this package.
Help for individual functions is also obtained by adding the
suffix '.spam' to the function name, e.g. 'help( chol.spam)'.
Attaching package: 'spam'
The following objects are masked from 'package:base':
backsolve, forwardsolve
Loading required package: sp
Loading required package: Matrix
Checking rgeos availability: TRUE
Warning message:
use rgdal::readOGR or sf::st_read
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.