mlen: Mean Length Estimation for Embedded Markov Chain

View source: R/mlen.R

mlenR Documentation

Mean Length Estimation for Embedded Markov Chain

Description

The function estimates the mean length for a d-D spatial embedded Markov chain for a specified direction \phi.

Usage

mlen(data, coords, loc.id, direction, mle = "avg")

Arguments

data

a categorical data vector of length n.

coords

an n \times d matrix where each row denotes the d-D coordinates of data locations.

loc.id

a vector of n values which indicates the directional line of each location. It is usually the output of the function which_lines.

direction

a d-D numerical vector (or versor) which represents the chosen direction.

mle

a character value. If "trm", the trimmed arithmetic average will be used to calculate the mean lengths. If "mdn", the trimmed median will be considered. If "mlk", the maximum likelihood mean lengths will be computed. If "avg", the arithmetic mean will be performed. For backward compatibility reasons, it can accept logical values, so that TRUE is equivalent to "mlk" and FALSE to "avg".

Details

The mean length is the total length occupied by the k-th category divided by the number of its embedded occurrences along lines in the direction \phi. More robust methods are implemented, such as the trimmed mean and the trimmed median.

If the stratum lengths are censored, the maximum likelihood approach is more appropriate than the arithmetic mean. In this case, the stratum lengths are assumed to be independent realizations from a log-normal random variable. The quantity to maximize is

L(\mu_1, \ldots, \mu_K, \sigma_1, \ldots, \sigma_K) = \prod_{i = 1}^m \prod_{k = 1}^K \left[ \int_{l_i}^{l_i+u_i} \frac{1}{x \sigma_k \sqrt{2}} \exp \left\lbrace - \frac{(\log x - \mu_k)^2}{2 \sigma_k^2} \right\rbrace \right]^{z_{k, i}} \mbox{d}x,

where \boldsymbol{\mu} = (\mu_1, \ldots, \mu_K)^\top and \boldsymbol{\sigma} = (\sigma_1, \ldots, \sigma_K)^\top are vectors of parameters, l_i is the observed stratum length, u_i denotes the upper bound of the censor and z_{k, i} denotes a dummy variable which assumes value 1 if and only if the i-th stratum is referred to the k-th category.

Value

A numeric vector containing the mean length for each observed category.

Author(s)

Luca Sartore drwolf85@gmail.com

References

Carle, S. F., Fogg, G. E. (1997) Modelling Spatial Variability with One and Multidimensional Continuous-Lag Markov Chains. Mathematical Geology, 29(7), 891-918.

Sartore, L. (2010) Geostatistical models for 3-D data. M.Phil. thesis, Ca' Foscari University of Venice.

See Also

which_lines

Examples


data(ACM)
direction <- c(0,0,1)

# Compute the appartaining directional line for each location
loc.id <- which_lines(ACM[, 1:3], direction)

# Estimate the mean lengths for each observed category
ml <- mlen(ACM$MAT5, ACM[, 1:3], loc.id, direction, mle = "avg")

# Equivalently
gl <- getlen(ACM$MAT5, ACM[, 1:3], loc.id, direction, zero.allowed = TRUE)
ml1 <- tapply(gl$length, gl$categories, mean)

spMC documentation built on May 3, 2023, 9:13 a.m.