ptwise.envelope: Pointwise Statistics on an Envelope Object

View source: R/ptwise.R

ptwise.envelopeR Documentation

Pointwise Statistics on an Envelope Object

Description

Compute pointwise statistics from the simulated function values in an envelope object.

Usage

ptwise.envelope(object,
                stats=c("mean", "median", "bias",
                        "var", "sd", "se", "mse", "rmse",
                        "confint", "predint"),
               ...,
               level=0.95, transform=NULL, theo=NULL)

bias.envelope(object, theo, CI=TRUE, level=0.95)

RMSE.envelope(object, theo)

Arguments

object

An object of class "envelope" generated by the function envelope

stats

Summary statistic(s) to be calculated. A character string or character vector (partially matched) selected from the options given, or a function(x) provided by the user to compute the summary statistic.

...

Arguments passed to stats if it is a function.

level

Confidence level required for confint or predint. A probability value between 0 and 1.

transform

Optional expression (passed to with.fv) which should be applied to the function values before the summary statistics are calculated.

theo

Function in the R language that evaluates the true (theoretically expected) value of the spatial summary function. This is required if stats includes "bias", "mse" or "rmse".

CI

Logical value specifying whether to calculate confidence interval as well as bias.

Details

These functions compute pointwise summary statistics from n spatial summary functions which were obtained from n simulated point patterns.

The object should have been generated by the function envelope with the argument savefuns=TRUE specified.

The function envelope is normally used to generate simulation envelopes for a particular spatial summary function, such as the K function, by simulating n realisations of Complete Spatial Randomness or another model. However, when envelope is called with the argument savefuns=TRUE, it returns all the individual summary functions for the n simulated point patterns.

These individual functions are extracted by ptwise.envelope which then computes the desired summary statistics. The argument stats specifies the desired summary statistics. It can be a character string, or vector of character strings, containing any of the following (partially matched):

mean

the pointwise sample mean of the functions

median

the pointwise sample median of the functions

bias

the pointwise bias of the functions

var

the pointwise sample variance of the functions

sd

the pointwise sample standard deviation of the functions

se

the standard error of the pointwise sample mean

mse

the pointwise mean squared error

rmse

the pointwise root-mean-squared error

confint

a confidence interval for the true mean

predint

a prediction interval for the function value

For confint or predint the argument level specifies the confidence level.

Alternatively, the argument stats can be a user-specified function in the R language, which computes the summary statistic. It should accept a vector argument and return a single numerical value.

The result is an object of class "fv" that can be plotted directly. See the Examples for different styles of plot.

The functions bias.envelope and RMSE.envelope are wrappers for ptwise.envelope which calculate the bias and root-mean-square error respectively.

Value

A function value table (object of class "fv") containing some or all of the following columns

r

Distance argument r

mean

Pointwise sample mean

median

Pointwise sample median

bias

Pointwise estimated bias

var

Pointwise sample variance

sd

Pointwise sample standard deviation

se

Pointwise standard error of pointwise mean

mse

Pointwise estimated mean squared error

rmse

Pointwise estimated root-mean-squared error

loci, hici

Pointwise confidence interval for the true mean

lopi, hipi

Pointwise prediction interval for the function value

Author(s)

\spatstatAuthors

, \tilman and \martinH.

See Also

ISB.envelope, IV.envelope, ISE.envelope, MISE.envelope.

Examples

    E <- envelope(cells, Kest, nsim=20, savefuns=TRUE)
    plot(ptwise.envelope(E, c("mean", "confint"), level=0.9))
    plot(ptwise.envelope(E, max, na.rm=TRUE))

    ## statistics for L function
    plot(ptwise.envelope(E, c("mean","confint"),
         transform=quote(sqrt(./pi)), level=0.9))

    ## calculate pointwise bias and RMSE
    ## using the theoretical true value K(r) = pi * r^2
    trueK <- function(r) { pi * r^2 }
    plot(bias.envelope(E, theo=trueK))
    plot(RMSE.envelope(E, theo=trueK))

spatstat.explore documentation built on April 4, 2025, 2:49 a.m.