mle

Why do I get negative variance from hessian matrix in optim function

 ̄綄美尐妖づ 提交于 2021-01-29 14:14:33
问题 I try to estimate mle parameters of a generalised gamma distribution. I use optim function with a lower bound equal to one (since parameters must be positive) and BFGS method. Initially, I estimate the log likelihood function as below: negloglikgengamma<-function(thet,dat) { alpha<-thet[1] kappa<-thet[2] lamda<-thet[3] -sum(dggamma(y,scale=alpha,shape1=kappa,shape2=lamda,log=T)) } I use minus log likelihood function in order to use "optim" and find the minimum. Then I use optim function.

How do I plot a mle2 fit of a model in ggplot2, along with the data?

核能气质少年 提交于 2021-01-29 11:11:25
问题 I created a log likelihood function for the model, and use this with starting values in mle2() to fit the model (see blow), but can't figure out how to plot this model fit over top of the data in ggplot2. I've never posted on this site before, so I'm not sure where to put the data file, but I have one for reproducibility if needed. I have spent days trying to find an example of specifically what I need to do, and can't find anything relevant. Apparently stat_smooth has most fitting options

How to find the MLE of a uniform distribution?

大城市里の小女人 提交于 2020-05-16 06:33:21
问题 I am trying to find the maximum likelihood estimators a_hat and b_hat for a given uniform distribution X ~ UNIF(1,3) using R. Below is my code and its output: ##Example: Uniform Distribution x<-runif(100,1,3) n<-length(x) ll<-function(a,b){ -sum(1/(b-a)^n,log=TRUE) } m0<-mle2(ll,start=list(a=1,b=2)) summary(m0) > summary(m0) Maximum likelihood estimation Call: mle2(minuslogl = ll, start = list(a = 1, b = 2)) Coefficients: Estimate Std. Error z value Pr(z) a 1.5159 NA NA NA b 1.4841 NA NA NA

How to find the MLE of a uniform distribution?

孤人 提交于 2020-05-16 06:32:08
问题 I am trying to find the maximum likelihood estimators a_hat and b_hat for a given uniform distribution X ~ UNIF(1,3) using R. Below is my code and its output: ##Example: Uniform Distribution x<-runif(100,1,3) n<-length(x) ll<-function(a,b){ -sum(1/(b-a)^n,log=TRUE) } m0<-mle2(ll,start=list(a=1,b=2)) summary(m0) > summary(m0) Maximum likelihood estimation Call: mle2(minuslogl = ll, start = list(a = 1, b = 2)) Coefficients: Estimate Std. Error z value Pr(z) a 1.5159 NA NA NA b 1.4841 NA NA NA

How to find the MLE of a uniform distribution?

北战南征 提交于 2020-05-16 06:32:03
问题 I am trying to find the maximum likelihood estimators a_hat and b_hat for a given uniform distribution X ~ UNIF(1,3) using R. Below is my code and its output: ##Example: Uniform Distribution x<-runif(100,1,3) n<-length(x) ll<-function(a,b){ -sum(1/(b-a)^n,log=TRUE) } m0<-mle2(ll,start=list(a=1,b=2)) summary(m0) > summary(m0) Maximum likelihood estimation Call: mle2(minuslogl = ll, start = list(a = 1, b = 2)) Coefficients: Estimate Std. Error z value Pr(z) a 1.5159 NA NA NA b 1.4841 NA NA NA

Estimating the parameters of a custom distribution using mle()

泪湿孤枕 提交于 2020-02-03 04:15:31
问题 I have the following code that I wish to estimate the parameters of a custom distribution. For more details on the distribution. Then using the estimated parameters I want to see if the estimated PDF resembles the distribution of the given the data (it is supposed to match the distribution of the given data). [EDIT]: 'x' now holds a sample of data and not a PDF The main code is: x = [0.0320000000000000 0.0280000000000000 0.0280000000000000 0.0270000000000000 0.0320000000000000 0

Calculation of return levels based on a GPD in different R packages

梦想的初衷 提交于 2020-01-23 08:30:15
问题 I am performing an extreme value analysis for meteorological data, to be precise for precipitation data available in mm/d. I am using a threshold excess approach for estimating the parameters of a generalized Pareto distribution with a maximum likelihood method. The aim is to calculate several return levels (i.e. the 2, 5, 10, 20, 50, 100 year event) for daily precipitation. While the R code works fine, I am wondering why I get clearly different results when calculating return levels based on

Nonlinear least square in r

流过昼夜 提交于 2020-01-17 05:31:08
问题 Check please, there is a good fit or not. I have two vectors here: x=c(30,110) y=c(0.000760289, 0.000800320, 0.000830345, 0.000840353, 0.000860370, 0.000910414, 0.000990490, 0.001090594, 0.001200721, 0.001350912, 0.001531172, 0.001751533, 0.001961923, 0.002192402, 0.002463031, 0.002793899, 0.003185067, 0.003636604, 0.004148594, 0.004721127, 0.005394524, 0.006168989, 0.007014544, 0.007870894, 0.008758242, 0.009656474, 0.010565620, 0.011485709, 0.012396520, 0.013308162, 0.014271353, 0.015326859

Weibull Distribution parameter estimation error

雨燕双飞 提交于 2020-01-06 08:28:13
问题 I used the following function to estimate the three-parameter Weibull distribution. library(bbmle) library(FAdist) set.seed(16) xl=rweibull3(50, shape = 1,scale=1, thres = 0) dweib3l <- function(shape, scale, thres) { -sum(dweibull3(xl , shape, scale, thres, log=TRUE)) } ml <- mle2(dweib3l, start= list(shape = 1, scale = 1, thres=0), data=list(xl)) However, when I run the above function I am getting the following error. Error in optim(par = c(shape = 1, scale = 1, thres = 0), fn = function (p

Using MLE function to estimate the parameters of a custom distribution

房东的猫 提交于 2019-12-29 09:05:25
问题 I am trying to use mle() function in MATLAB to estimate the parameters of a 6-parameter custom distribution. The PDF of the custom distribution is and the CDF is where Γ (x,y) and Γ (x) are the upper incomplete gamma function and the gamma function , respectively. α , θ , β , a , b , and c are the parameters of the custom distribution. K is given by Given a data vector ' data ', I want to estimate the parameters α , θ , β , a, b, and c. So, far I have come up with this code: data = rand(20000