P | R Documentation |
P
Compute the cumulative distribution function for multiple distributions
P(
q,
dist = "normal",
lower.tail = TRUE,
rounding = 5,
porcentage = FALSE,
gui = "plot",
main = NULL,
...
)
q |
quantile. The |
dist |
distribution to use. The default is |
lower.tail |
logical; if |
rounding |
numerical; it represents the number of decimals for calculating the probability. |
porcentage |
logical; if |
gui |
default is |
main |
defalt is |
... |
additional arguments according to the chosen distribution. |
The argument that can have length 2, when we use the functions that give us the probability regions, given by: %<X<%
, %<=X<%
, %<X<=%
, %<=X<=%
, %>X>%
, %>X=>%
, %>X=>%
and %>=X=>%
.
The additional arguments represent the parameters of the distributions, that is:
If dist = "normal"
(Default); the additional arguments are: mean
(\mu
) and sd
(\sigma
). The PDF is given by:
\displaystyle{f_X(x; \mu, \sigma) = \frac {1}{\sqrt {2\pi \sigma ^{2}}}}e^{-{\frac {(x-\mu )^{2}}{2\sigma ^{2}}}}, \quad x \in \mathbb{R},~ \mu \in \mathbb{R},~\sigma^2 > 0;
If dist = "t-student"
; the additional argument is: df
(\nu
). The PDF is given by:
\displaystyle{f_X(x; \nu) = \frac {\Gamma \left({\frac {\ \nu +1\ }{2}}\right)}{{\sqrt {\pi \ \nu \ }}\ \Gamma \left({\frac {\nu }{\ 2\ }}\right)}}\left(\ 1+{\frac {~x^{2}\ }{\nu }}\ \right)^{-{\frac {\ \nu +1\ }{2}}}, \quad x \in \mathbb{R},~\nu > 1;
If dist = "chisq"
; the additional argument is: df
(\nu
). The PDF is given by:
\displaystyle{f_X(x; \nu) = \frac {1}{2^{k/2}\Gamma (k/2)}}\;x^{k/2-1}e^{-x/2}, \quad x > 0,~\nu > 0;
If dist = "f"
; the additional argument is: df1
(\nu_1
) and df2
(\nu_2
). The PDF is given by:
f_X(x; \nu_1, \nu_2) = {\displaystyle {\frac {\sqrt {\frac {(\nu_{1}x)^{\nu_{1}}\nu_{2}^{\nu_{2}}}{(\nu_{1}x+\nu_{2})^{\nu_{1}+\nu_{2}}}}}{x\,\mathrm {B} \!\left({\frac {\nu_{1}}{2}},{\frac {\nu_{2}}{2}}\right),}}\!}, \quad x > 0,~\nu_1,\nu_2 > 0;
where, x > 0
, \nu_1,~\nu_2
> 0, and B
is the beta function.
The ncp
parameter (\lambda \in \mathbb{R}
) represents the noncentrality parameter. The PDFs presented graphically do not take this parameter into account. However, to reinforce the importance of this parameter
in the three distributions (Student's t-distribution, F-distribution and Chi-squared distribution), especially when studying hypothesis testing, we present their distributions taking into account the ncp
parameter, as follows:
The PDF for the noncentral t-distribution with \nu > 0
degrees of freedom and noncentrality parameter \lambda
is based on the pt function. If Z
is a standard normal random variable, and V
is a chi-squared distribution random variable with \nu
degrees of freedom that is independent of Z
, then T = (Z + \lambda) / \sqrt{V / \nu}
is
a noncentral t-distributed random variable with \nu
degrees of freedom and noncentrality parameter \lambda
. If \lambda = 0
, the PDF reduces to the probability density function of the Student's t-distribution. However, it is worth noting that the parameter \lambda \in \mathbb{R}
.
P
returns the probability and its graphical representation. The result can be given as a percentage or not.
# Loading package
library(leem)
# Example 1 - Student's t distribution
## Not run:
P(q = 2, dist = "t-student", df = 10)
P(q = 2, dist = "t-student", df = 10, gui = 'rstudio')
P(q = 2, dist = "t-student", df = 10, gui = 'tcltk')
P(-1 %<X<% 1, dist = "t-student", df = 10)
## End(Not run)
# Example 2 - Normal distribution
P(-2, dist = "normal", mean = 3, sd = 2,
main = expression(f(x) == (1 / sqrt(n * sigma^2)) *
exp(-1/2 * (x - mu)^2/sigma^2)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.