Learn R Programming

binspp (version 0.2.3)

simulate.output_estintp: Simulation from the fitted model

Description

One or more point patterns are simulated using the point estimates provided by the MCMC output.

Usage

# S3 method for output_estintp
simulate(object, nsim = 1, seed = NULL, ...)

Value

Either a single point pattern or a list of point patterns.

Arguments

object

list, output of the main function estintp().

nsim

number of patterns to be simulated.

seed

a single value, interpreted as an integer, or NULL.

...

additional optional arguments.

Details

A given number of point patterns is simulated from the fitted model. The point pattern used for estimation determines the observation window and the covariates to be used. Point estimates from the output of the MCMC run are used as parameter values.

Examples

Run this code

library(spatstat)
library(stats)
# Prepare the dataset:
X <- trees_N4
x_left <- x_left_N4
x_right <- x_right_N4
y_bottom <- y_bottom_N4
y_top <- y_top_N4

z_beta <- list(refor = cov_refor, slope = cov_slope)
z_alpha <- list(tmi = cov_tmi, tdensity = cov_tdensity)
z_omega <- list(slope = cov_slope, reserv = cov_reserv)

# Determine the union of rectangles:
W <- owin(c(x_left[1], x_right[1]), c(y_bottom[1], y_top[1]))
if (length(x_left) >= 2) {
  for (i in 2:length(x_left)) {
    W2 <- owin(c(x_left[i], x_right[i]), c(y_bottom[i], y_top[i]))
    W <- union.owin(W, W2)
  }
}

# Dilated observation window:
W_dil <- dilation.owin(W, 100)


# Default parameters for prior distributions:
control <- list(NStep = 100, BurnIn = 20, SamplingFreq = 5)


# MCMC estimation:
Output <- estintp(X = X, control = control, x_left = x_left, x_right = x_right,
    y_bottom = y_bottom, y_top = y_top, W_dil = W_dil, z_beta = z_beta,
    z_alpha = z_alpha, z_omega = z_omega, verbose = FALSE)


# Simulation from the fitted model:
pattern <- simulate(Output)
plot(pattern)

Run the code above in your browser using DataLab