stgmix {spagmix}R Documentation

Trivariate Gaussian mixture density generation

Description

Generates a pixel image array of a specified trivariate normal mixture density observed on a bounded window in space and time.

Usage

stgmix(mean, vcv, window, tlim, p0 = 0, p = NULL, sres = 128, tres = sres, int = 1)

Arguments

mean

A 3 x N matrix specifying the means of each of N contributing normal densities; each component in the order of (x-coord, y-coord, time-coord).

vcv

A 3 x 3 x N array specifying the variance-covariance matrices of each contributing density.

window

An object of class owin giving the spatial observational window on which the mixture density is defined.

tlim

A vector of length 2 giving the boundaries of the time interval on which the mixture density is defined.

p0

The proportion of uniform density that contributes to the final mixture (default is 0).

p

A numeric vector of the N proportions for each contributing density (default is equal proportions for each density, after subtracting p0). Together, p0 and p must sum to exactly 1.

sres

The spatial resolution (number of pixels) along each side of the spatial grid (default is 128).

tres

The temporal resolution (default is to equate with sres).

int

A positive numeric value for post-hoc rescaling of the density (useful if the user wishes to return a spatiotemporal intensity function). Defaults to 1 for no change in scaling.

Details

This function creates a 3D array of a density function made up of a mixture of N trivariate normals with the interpretation of a continuous probability density function in space-time. As such, each component is restricted to conserve mass over a 3D region specified by a fixed polygonal window in space, stretched over defined temporal limits (tlim). A warning will appear if less than 1% of the integral of each Gaussian bump is inside this observational spatiotemporal polyhedron.

Value

An object of class stim giving the trivariate density. This is a list with six components:

a

The sres x sres x tres array of the specified density.

v

A pixel image version of a, provided as a solist of length tres, with each member being the spatial image slice of the 3D density at each of the time-coordinate values.

xcol

Grid coordinates in the spatial x-axis (corresponds to each spatial image in v).

yrow

Grid coordinates in the spatial y-axis (corresponds to each spatial image in v).

tlay

Grid coordinates in the temporal axis (corresponds to the order of the spatial images in v).

W

A copy of window, the spatial owin upon which the density is defined.

Author(s)

A.K. Redmond and T.M. Davies

Examples


require("abind")
m1 <- c(0.3,0.3,2)
m2 <- c(0.5,0.8,8)
m3 <- c(0.7,0.6,7)
v1 <- diag(c(0.01^2,0.01^2,1))
v2 <- diag(c(0.005,0.005,0.5))
v3 <- diag(c(0.005,0.005,0.5))
stg1 <- stgmix(mean=cbind(m1,m2,m3),
               vcv=abind(v1,v2,v3,along=3),
               window=toywin,tlim=c(1,10),
               p0=0.1,tres=64)
plot(stg1,log=TRUE)


mn <- matrix(c(0,0,0,-2,1,4,1,-2,8),nrow=3)
vr <- array(c(1,0,0,0,1,0,0,0,1,1,0,0.5,0,1,0,0.5,0,3,1,0,0,0,2,0,0,0,1),
            dim=c(3,3,3))
stg2 <- stgmix(mean=mn,vcv=vr,window=shp1,
               tlim=c(0,10),tres=50)
plot(stg2,fix.range=TRUE,sleep=0.1)


[Package spagmix version 0.4-2 Index]