# rtcmvnorm

From MCMCglmm v2.29
by Jarrod Hadfield

##### Random Generation from a Truncated Conditional Normal Distribution

Samples from the Truncated Conditional Normal Distribution

- Keywords
- distribution

##### Usage

`rtcmvnorm(n = 1, mean = 0, V = 1, x=0, keep=1, lower = -Inf, upper = Inf)`

##### Arguments

- n
integer: number of samples to be drawn

- mean
vector of means

- V
covariance matrix

- x
vector of observations to condition on

- keep
element of x to be sampled

- lower
left truncation point

- upper
right truncation point

##### Value

vector

##### Examples

```
# NOT RUN {
par(mfrow=c(2,1))
V1<-cbind(c(1,0.5), c(0.5,1))
x1<-rtcmvnorm(10000, c(0,0), V=V1, c(0,2), keep=1, lower=-1, upper=1)
x2<-rtnorm(10000, 0, 1, lower=-1, upper=1)
plot(density(x1), main="Correlated conditioning observation")
lines(density(x2), col="red")
# denisties of conditional (black) and unconditional (red) distribution
# when the two variables are correlated (r=0.5)
V2<-diag(2)
x3<-rtcmvnorm(10000, c(0,0), V=V2, c(0,2), keep=1, lower=-1, upper=1)
x4<-rtnorm(10000, 0, 1, lower=-1, upper=1)
plot(density(x3), main="Uncorrelated conditioning observation")
lines(density(x4), col="red")
# denisties of conditional (black) and unconditional (red) distribution
# when the two variables are uncorrelated (r=0)
# }
```

*Documentation reproduced from package MCMCglmm, version 2.29, License: GPL (>= 2)*

### Community examples

Looks like there are no examples yet.