My probability distribution function is
f(x;r)=(1+r)/Γ(1/(1+r))exp(-x^(1+r)) , 0<x<Inf, r>-1
I am using following code:
library(stats4)
x3=c(0.927869895,0.000559193,0.059761785,0.361542986,0.274291999,0.563373589,
0.565878385,0.126281994,0.46623362,0.796111638,0.809460469,0.28011156,
0.263443012,0.704551045,0.978333171,0.139962088,0.599336759,0.108009066,
0.202133384,0.05401611)
nLL <- function(r)-sum(log(1+r)-log(gamma(1/(1+r)))-x3^(1+r))
fit0 <- mle(nLL, start = list(r = 0.1), nobs = NROW(x3))
fit1 <- mle(nLL, start = list(r = 0.1), nobs = NROW(x3),
method = "Brent", lower = -1, upper = 150)
stopifnot(nobs(fit0) == length(x3))
Now I want to extract value of MLE stored in fit1
. I have used following command
fitv = fit1$Coefficients
But I am unable to get the value as it give following error
Error in fit1$Coefficients : $ operator not defined for this S4 class
Now I get the answer
nLL <- function(r)-sum(log(1+r)-log(gamma(1/(1+r)))-x1^(1+r))
fit0 <- mle(nLL, start = list(r = 0.1), nobs = NROW(x1))
fit1 <- mle(nLL, start = list(r = 0.1), nobs = NROW(x1),
method = "Brent", lower = -1, upper = 200)
stopifnot(nobs(fit0) == length(x1))
class(fit1)
str(fit1)
fiteg[k] = fit1@coef