Learn R Programming

SpatialTools (version 1.0.5)

rcondnorm: Generate from conditional normal distribution

Description

Generates realizations from a multivariate normal distribution conditional on observed data vector

Usage

rcondnorm(nsim = 1, y, mu, mup, V, Vp, Vop, method = "eigen")

Value

An \(np \times nsim\) matrix containing the nsim realizations of the conditional normal distribution. Each column of the matrix represents a realization of the multivariate normal distribution.

Arguments

nsim

An integer indicating the number of realizations from the distribution.

y

A vector of length n contained the observed data.

mu

The mean vector of the observed data. Should be a vector of length n.

mup

The mean vector of the responses to be generated. Should be a vector of length np.

V

The covariance matrix of the observed data. The matrix should be symmetric and positive definite. The size must be \(n times n\).

Vp

The covariance matrix of the responses to be generated. The matrix should be symmetric and positive definite. The size must be \(np times np\).

Vop

The cross-covariance matrix between the observed data and the responses to be generated. The size must be \(n times np\).

method

The method for performing a decomposition of the covariance matrix. Possible values are "eigen", "chol", and "svd", Eigen value decomposition, Cholesky decomposition, or Singular Value Decomposoition, respectively.

Author

Joshua French

See Also

rmvnorm

Examples

Run this code
n <- 100
np <- 100

mu <- rep(1, 100)
mup <- rep(2, 100)

coords <- matrix(runif(2 * n), ncol = 2)
pcoords <- matrix(runif(2 * np), ncol = 2)

myV <- cov.sp(coords, sp.type = "exponential", c(1, 2), error.var = 1, pcoords = pcoords)

y <- rmvnorm(1, mu = mu, V = myV$V)

rcondnorm(3, y = y, mu = mu, mup = mup, V = myV$V, Vp = myV$Vp, Vop = myV$Vop, method = "chol")

Run the code above in your browser using DataLab