# rgmix: Random bivariate Gaussian mixture density generation In spagmix: Artificial Spatial and Spatiotemporal Densities on Bounded Windows

## Description

Generates a pixel image of a bivariate normal mixture density observed on a bounded window using a specified number of contributing densities with randomly selected means and variance-covariance matrices.

## Usage

 1 rgmix(N, window, v = 4, S = NULL, extras = FALSE, ...) 

## Arguments

 N The number of Gaussian components to generate for the mixture. window An object of class owin giving the observational window on which the mixture density is defined. v The degrees of freedom for the inverse-Wishart distribution of the variance-covariance matrices (must be at least 4). The default value of 4 ensures the generated covariance matrices are centered on S. S A symmetric, positive-definite 2 \times 2 scale matrix for the inverse-Wishart distribution of the variance-covariance matrices. extras A logical value indicating whether, in addition to returning the pixel image of the final mixture density, to also return the randomly realised mean locations and corresponding variance-covariance matrices. See ‘Value’. ... Additional arguments to be passed to sgmix. See ‘Details’.

## Details

This function creates and returns a bivariate Gaussian mixture density on a bounded window based on N randomly generated mean locations and corresponding randomly generated variance-covariance matrices. First, the N mean locations are generated based on a uniform distribution over the spatial window. Each location is then associated with a covariance matrix generated from an inverse-Wishart distribution with v degrees of freedom and scale matrix S.

Once the above steps are completed, the function calls sgmix with the chosen mean and covariance matrices, thereby creating the Gaussian mixture. Resolution and other aspects of this call can be controlled by using ..., passing the contents internally to sgmix. By default, all generated Gaussian components have equal weight in contributing to the final mixture density. The user can alter this by passing p0 and p to the ..., though should take care that the length of p is N, and that p0 and p sum to 1, as outlined in the documentation for sgmix.

## Value

If extras = FALSE (default), then a pixel image of the final mixture density. If extras = TRUE, a list is returned with members f (the pixel image of the final mixture density); mn (a 2 \times N matrix with each column giving the mean location of each of the N Gaussian bumps); and vcv (a 2 \times 2 \times N array with layers giving the covariance matrices associated with the means in the columns of mn).

## Author(s)

A.K. Redmond and T.M. Davies

## Examples

  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 set.seed(321) dens1 <- rgmix(7,window=toywin) plot(dens1) set.seed(456) dens2 <- rgmix(7,window=toywin) plot(dens2) # Explicitly return details of generated means and covariances set.seed(321) dens1.detailed <- rgmix(7,window=toywin,extras=TRUE) dens1.detailed$f dens1.detailed$mn dens1.detailed\$vcv # Set underlying uniform proportion and compare with dens2 from above set.seed(456) dens2.wunif <- rgmix(7,window=toywin,p0=0.3) par(mfrow=c(1,2)) plot(rpoint(500,dens2)) plot(rpoint(500,dens2.wunif)) # Explicitly setting scale matrix for inverse-wishart generation of covariances dens3 <- rgmix(3,window=toywin,S=matrix(c(0.025,-0.004,-0.004,0.02),2)) plot(dens3) 

spagmix documentation built on May 2, 2019, 7:24 a.m.