tnorm                  package:msm                  R Documentation

_T_r_u_n_c_a_t_e_d _N_o_r_m_a_l _d_i_s_t_r_i_b_u_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     Density, distribution function, quantile function and random
     generation for the truncated Normal distribution with mean equal
     to 'mean' and standard deviation equal to 'sd' before truncation,
     and truncated on the interval '[lower, upper]'.

_U_s_a_g_e:

          dtnorm(x, mean=0, sd=1, lower=-Inf, upper=Inf, log = FALSE)
          ptnorm(q, mean=0, sd=1, lower=-Inf, upper=Inf, lower.tail = TRUE, log.p = FALSE)
          qtnorm(p, mean=0, sd=1, lower=-Inf, upper=Inf, lower.tail = TRUE, log.p = FALSE)
          rtnorm(n, mean=0, sd=1, lower=-Inf, upper=Inf)

_A_r_g_u_m_e_n_t_s:

     x,q: vector of quantiles.

       p: vector of probabilities.

       n: number of observations. If 'length(n) > 1', the length is
          taken to be the number required.

    mean: vector of means.

      sd: vector of standard deviations.

   lower: lower truncation point.

   upper: upper truncation point.

log, log.p: logical; if TRUE, probabilities p are given as log(p).

lower.tail: logical; if TRUE (default), probabilities are P[X <= x],
          otherwise, P[X > x].

_D_e_t_a_i_l_s:

     The truncated normal distribution has density


 f(x, mu, sigma) = phi(x, mu, sigma) / (Phi(upper, mu, sigma) - Phi(lower, mu, sigma))

     for lower <= x <= upper, and 0 otherwise. 

     mean is the mean of the original Normal distribution before
     truncation, 
      sd is the corresponding standard deviation, 
      u  is the upper truncation point, 
      l is the lower truncation point, 
      phi(x) is the density of the corresponding normal distribution,
     and 
      Phi(x) is the distribution function of the corresponding normal
     distribution.

     If 'mean' or 'sd' are not specified they assume the default values
     of '0' and '1', respectively.

     If 'lower' or 'upper' are not specified they assume the default
     values of '-Inf' and 'Inf', respectively, corresponding to no
     lower or no upper truncation.

     Therefore, for example, 'dtnorm(x)', with no other arguments, is
     simply equivalent to 'dnorm(x)'.

     Only 'rtnorm' is used in the 'msm' package, to simulate from
     hidden Markov models with truncated normal distributions. These
     functions are merely provided for completion, and are not
     optimized for numerical stability.  To fit a hidden Markov model
     with a truncated Normal response distribution, use a 'hmmTNorm'
     constructor. See the 'hmm-dists' help page for further details.

_V_a_l_u_e:

     'dtnorm' gives the density, 'ptnorm' gives the distribution
     function, 'qtnorm' gives the quantile function, and 'rtnorm'
     generates random deviates.

_A_u_t_h_o_r(_s):

     C. H. Jackson chris.jackson@imperial.ac.uk

_S_e_e _A_l_s_o:

     'dnorm'

_E_x_a_m_p_l_e_s:

     x <- seq(50, 90, by=1)
     plot(x, dnorm(x, 70, 10), type="l", ylim=c(0,0.06)) ## standard Normal distribution
     lines(x, dtnorm(x, 70, 10, 60, 80), type="l")       ## truncated Normal distribution

