Skip to contents

Computes the probability density, the cumulative distribution function and the quantile function and generates random samples for the externally studentized normal midrange distribution with the numbers means equal to size, the degrees of freedom equal to df and the number of points of the Gauss-Legendre quadrature equal to np.

Usage

dSMR(x, size, df, np=32, log = FALSE)
pSMR(q, size, df, np=32, lower.tail = TRUE, log.p = FALSE)
qSMR(p, size, df, np=32, eps = 1e-13, maxit = 5000, lower.tail = TRUE, log.p = FALSE)
rSMR(n, size,  df = Inf)

Arguments

x, q

vector of quantiles \(x \in R\) and \(q \in R\).

p

vector of probabilities \((0, 1)\).

size

sample size. Only for \(size > 1\).

n

vector size to be simulated \(n > 1\).

df

degrees of freedom \(df > 0\).

np

number of points of the gaussian quadrature \(np > 2\).

log, log.p

logical argument; if TRUE, the probabilities \(p\) are given as \(log(p)\).

lower.tail

logical argument; if TRUE, the probabilities are \(P[X \leq x]\) otherside, \(P[X \geq x].\)

eps

stopping criterion for Newton-Raphson's iteraction method.

maxit

maximum number of interaction in the Newton-Raphson method.

Details

Assumes np = 32 as default value for dSMR, pSMR and qSMR. If df is not specified, it assumes the default value Inf in rSMR. When df=1, the convergence of the routines requires np>250 to obtain the desired result accurately. The Midrange distribution has density

$$f(\overline{q};n,\nu) =\int^{\infty}_{0} \int^{x\overline{q}}_{-\infty}2n(n-1)x\phi(y) \phi(2x\overline{q}-y)[\Phi(2x\overline{q}-y)-\Phi(y)]^{n-2}f(x;\nu)dydx,$$

where, \(q\) is the quantile of externally studentized midrange distribution, \(n\) (size) is the sample size and \(\nu\) is the degrees of freedon.

The externally studentized midrange distribution function is given by $$ F(\overline{q};n,\nu)=\int^{\overline{q}}_{-\infty} \int^{\infty}_{0}\int^{x\overline{q}}_{-\infty}2n(n-1)x\phi(y) \phi(2xz-y)[\Phi(2xz-y)-\Phi(y)]^{n-2}f(x;\nu)dydxdz. $$ where, \(q\) is the quantile of externally studentized midrange distribution, \(n\) (size) is the sample size and \(\nu\) is the degrees of freedon.

Value

dSMR gives the density, pSMR gives the cumulative distribution function, qSMR gives the quantile function, and rSMRgenerates random deviates.

References

Batista, BDO; Ferreira, DF. The externally studentized normal midrange distribution. Submmited for publications. 2012.

Author

Ben Deivide de Oliveira Batista and Daniel Furtado Ferreira.

Maintainer: Daniel Furtado Ferreira

Examples

library(SMR)

#example 1:
x  <- 2
q  <- 1
p  <- 0.9
n  <- 30
size  <- 5
df <- 3
np <- 32
dSMR(x, size, df, np)
#> [1] 0.01926172
pSMR(q, size, df, np)
#> [1] 0.9275892
qSMR(p, size, df, np)
#> [1] 0.8350065
rSMR(n, size, df)
#>  [1] -0.02068743  0.77858823  0.29546709  0.05514410  0.18313829  1.17741330
#>  [7]  0.70916181 -0.08738732  0.01665665 -1.19008348 -0.22487655 -1.28955577
#> [13]  0.61787914 -0.18440686  1.01805963 -0.31358327  1.37266252 -1.04441467
#> [19]  0.55016967  0.81967698  0.10373011  0.96467175 -0.23268716 -0.27036517
#> [25]  0.98376392  0.58919367 -0.79584598 -0.09819476  0.21829588 -0.19893010

#example 2:
x  <- c(-1, 2, 1.1)
q  <- c(1, 0, -1.5)
p  <- c(0.9, 1, 0.8)
n  <- 10
size  <- 5
df <- 3
np <- 32
dSMR(x, size, df, np)
#> [1] 0.13805831 0.01926172 0.11052698
pSMR(q, size, df, np)
#> [1] 0.92758919 0.50000000 0.03033035
qSMR(p, size, df, np)
#> [1] 0.8350065       Inf 0.4981228
rSMR(n, size, df)
#>  [1] -0.19227009 -1.96243753  0.72813882 -0.35858015  0.60250231 -2.12672520
#>  [7]  0.58086350  0.03465036 -0.15616610  0.44558716