Description Usage Arguments Details Value Comment Examples
View source: R/trap_MLestimates.R
The function calculates the maximum likelihood (ML) estimates of the two parameters μ and σ, when a set of numbers are assumed to be normally distributed.
1 | MLestimates(x)
|
x |
A numeric vector. |
If a set of observations are assumed to be normally distributed, two parameters, mean μ and the variance (the square of σ) are to be estimated. In theory, the ML estimate of μ is the mean of the observations. And the ML estimate of square of σ is the mean squared deviation of the observations from the estimated μ.
A "list"
object of two numeric components,
μ and σ.
MLestimates
is used internally in other function(s) of ROCit.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # 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.