In: Statistics and Probability
How do you use R to derive the parameters maximizes the log-likelihood?
To calculate Maximum likelihood estimate of the parameter of a given distribution
R code is --
install.packages("EstimationTools")
library(EstimationTools)
maxlogL(x, dist, optimizer, lower = NULL, upper = NULL)
So, firstly we install the package EstimationTools.
For example, Let us apply this code for normal distribution
R code is -
set.seed(1000)
z <- rnorm(n = 1000, mean = 10, sd = 1)
fit1 <- maxlogL(x = z, dist = 'dnorm', start=c(2, 3),
lower=c(-15, 0), upper=c(15, 10))
summary(fit1)
Output is -
> set.seed(1000)
> z <- rnorm(n = 1000, mean = 10, sd = 1)
> fit1 <- maxlogL(x = z, dist = 'dnorm', start=c(2, 3),
+ lower=c(-15, 0), upper=c(15, 10))
> summary(fit1)
---------------------------------------------------------------
Optimization routine: nlminb
Standard Error calculation: Hessian from optim
---------------------------------------------------------------
AIC BIC
2804.033 2800.033
---------------------------------------------------------------
Estimate Std. Error
mean 9.98752 0.0310
sd 0.98126 0.0219
-----
Thus MLE for is 9.98752 and MLE for is 0.98126