Fnorm                  package:VGAM                  R Documentation

_T_h_e _F_o_l_d_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 (generalized) folded-normal distribution.

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

     dfnorm(x, mean=0, sd=1, a1=1, a2=1)
     pfnorm(q, mean=0, sd=1, a1=1, a2=1)
     qfnorm(p, mean=0, sd=1, a1=1, a2=1, ...)
     rfnorm(n, mean=0, sd=1, a1=1, a2=1)

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

    x, q: vector of quantiles.

       p: vector of probabilities.

       n: number of observations. Must be a positive integer of length
          1.

mean, sd: see 'rnorm'. 

  a1, a2: see 'fnormal1'. 

     ...: Arguments that can be passed into 'uniroot'.

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

     See 'fnormal1', the 'VGAM' family function for estimating the
     parameters,  for the formula of the probability density function
     and other details.

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

     'dfnorm' gives the density, 'pfnorm' gives the distribution
     function, 'qfnorm' gives the quantile function, and 'rfnorm'
     generates random deviates.

_N_o_t_e:

     'qfnorm' runs very slowly because it calls 'uniroot' for each
     value of the argument 'p'. The solution is consequently not exact;
     the '...' can be used to obtain a more accurate solution if
     necessary.

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

     T. W. Yee

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

     'fnormal1', 'uniroot'.

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

     ## Not run: 
     m = 1.5; SD=exp(0)
     x = seq(-1, 4, len=501)
     plot(x, dfnorm(x, m=m, sd=SD), type="l", ylim=0:1, las=1,
          ylab=paste("fnorm(m=", m, ", sd=", round(SD, dig=3), ")"), col="blue",
          main="Blue is density, red is cumulative distribution function",
          sub="Purple lines are the 10,20,...,90 percentiles")
     lines(x, pfnorm(x, m=m, sd=SD), col="red")
     abline(h=0)
     probs = seq(0.1, 0.9, by=0.1)
     Q = qfnorm(probs, m=m, sd=SD)
     lines(Q, dfnorm(Q, m=m, sd=SD), col="purple", lty=3, type="h")
     lines(Q, pfnorm(Q, m=m, sd=SD), col="purple", lty=3, type="h")
     abline(h=probs, col="purple", lty=3)
     max(abs(pfnorm(Q, m=m, sd=SD) - probs)) # Should be 0
     ## End(Not run)

