View source: R/trap_MLestimates.R
MLestimates | R Documentation |
The function calculates the maximum likelihood (ML) estimates
of the two parameters \mu
and \sigma
, when a set of numbers are
assumed to be normally distributed.
MLestimates(x)
x |
A numeric vector. |
If a set of observations
are assumed to be normally
distributed, two parameters, mean \mu
and the variance (the square
of \sigma
)
are to be estimated. In theory, the ML estimate of \mu
is the mean of the
observations. And the ML estimate of square of \sigma
is the mean
squared deviation of the observations from the estimated \mu
.
A "list"
object of two numeric components,
\mu
and \sigma
.
MLestimates
is used internally in other function(s) of ROCit.
# Find the two parameters
set.seed(10)
points <- rnorm(200, 10, 5)
ML <- MLestimates(points)
message("The ML estimates are: mean = ", round(ML$mu, 3),
" , SD = ", round(ML$sigma, 3))
#-----------------------------------------
# Superimpose smooth curve over hostogram
set.seed(100)
x <- rnorm(400)
hist(x, probability = TRUE, col = "gray90")
ML <- MLestimates(x)
x <- seq(-3, 3, 0.01)
density <- dnorm(x, mean = ML$mu, sd = ML$sigma)
lines(density~x, lwd = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.