rGRF: Generate a Gaussian Random Field

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

View source: R/other_funcs.R

Description

Generates Gaussian random fields (GRFs) and related fields via transformations. The spatial covariances are modeled using Matern's model.

For examples see

http://faculty.missouri.edu/~micheasa/sppmix/sppmix_all_examples.html#rGRF

Usage

1
2
rGRF(mu = 0, gentype = 0, xlims = c(-5, 5), ylims = c(-5, 5),
  LL = 128, df = 10, nu = 0.5, theta = 1, sig = 1, pattern)

Arguments

mu

Mean of the stationary GRF.

gentype

Set to 0 for Gaussian, 1 for Chi-square. Default is gentype=0.

xlims, ylims

Vectors defining the grid limits of the x-y locations over which to compute the covariance matrix.

LL

Length of the side of the square grid.

df

Degrees of freedom (an integer) for the chi-square random field when gentype=1.

nu, theta, sig

Matern model parameters. See MaternCov for details.

pattern

Optionally, a point pattern as an object of type ppp containing locations within the window. The values of the generated GRF over these locations are returned as the marks of the point pattern pattern.

Details

The code of the rGRF function uses a modification of the functions sim.rf and matern.image.cov from the fields package, by Douglas Nychka, Reinhard Furrer, John Paige, and Stephan Sain.

Depending on the choice of the Matern model parameters we might end up having trouble with the FFT giving negative values. The code accounts for this event and adjusts the range of values via an increasing variable incr. If it still takes a long time to generate the fields try increasing the domain of observation using wider xlims and ylims.

Value

An image as an object of class im.object, containing the realization of the field over the grid. If argument pattern was supplied, the return value is now a list contaning the realization of the field as an image, augmented by the marked point pattern with locations in pattern and marks the field values over these locations. This capability is illustrated for realizations of marked point processes conditioning on continuous marks. See function rMIPPP_cond_loc for more details.

Author(s)

Sakis Micheas

See Also

MaternCov, plot_density, ggtitle, add_title

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#Gaussian random field as an image
GRF1=rGRF()
p<-plot_density(as.data.frame(GRF1))
p_title<-expression( paste("GRF with Matern covariances, ", theta,"=1,",mu,"=0,",nu, "=.5,",
 sigma,"=1"))
p+ggplot2::ggtitle(p_title)
#or simply use the add_title function
p+add_title("GRF with Matern model covariances", mu=0,theta=1,nu=.5,sigma=1)
#Chi-Square random field as an image
ChiSqRF=rGRF(gentype=1,df=10)
p<-plot_density(as.data.frame(ChiSqRF))
p+add_title(paste(chi^{2}," random fields with Matern model covariances for the GRFs"),
mu=0,theta=1,nu=.5,sigma=1,df=10)
#Log-Gaussian random field as an image
GRF2=rGRF()
LogGRF=exp(rGRF())
p<-plot_density(as.data.frame(LogGRF))
p+add_title("Log-Gaussian random field with Matern model covariances", mu=0,theta=1,
 nu=.5,sigma=1)

sppmix documentation built on Jan. 13, 2021, 10:04 p.m.