Displaying 11 results from an estimated 11 matches for "minuslog".
Did you mean:
minuslogl
2008 Oct 09
2
Help MLE
...obtain the variables values (alpha12, w_g12, w_u12) that maximize
the function LL = Y*ln(alpha12 + g*w_g12 + u*w_u12).
Following the code:
rm(list=ls())
ls()
library(stats4)
Model = function(alpha12,w_g12,w_u12)
{
Y = 1
u = 0.5
g = -1
Y*log(alpha12 + g*w_g12 + u*w_u12)
}
res = mle(minuslog=Model,start=list(alpha12=0.1,w_u12=0.1,w_g12=0.1),
method = "BFGS")
res
Error message:
> res = mle(minuslog=Model,start=list(alpha12=0.1, w_u12=0.1, w_g12=0.1),
method = "BFGS")
Error in optim(start, f, method = method, hessian = TRUE, ...) :
non-finite finite-diffe...
2008 May 08
3
MLE for noncentral t distribution
...xample to find MLE for gamma distribution from "fitting distributions with R":
library(stats4) ## loading package stats4
ll<-function(lambda,alfa) {n<-200
x<-x.gam
-n*alfa*log(lambda)+n*log(gamma(alfa))-(alfa-
1)*sum(log(x))+lambda*sum(x)} ## -log-likelihood function
est<-mle(minuslog=ll, start=list(lambda=2,alfa=1))
Is anyone how how to write down -log-likelihood function for noncentral t distribution?
Thanks a lot!!
Kate
[[alternative HTML version deleted]]
2008 Oct 23
1
distribution fitting
...function(lambda_log, alfa_log) {
+ n <- length(interarrival_times)
+ x <- interarrival_times
+ -n*exp(alfa_log)*lambda_log + n*log(gamma(exp(alfa_log))) -
(exp(alfa_log)-1)*sum(log(x)) + exp(lambda_log)*sum(x)
+ }
and passed it to the mle function:
> est_gamma <- mle(minuslog = nll_gamma_log, start = list(lambda_log = 0,
alfa_log=0))
There were 50 or more warnings (use warnings() to see the first 50)
of course I got many "value out of range" warnings:
> warnings()
Warning messages:
1: In log(gamma(exp(log_alfa))) ... : value out of range in 'gammafn...
2005 Sep 06
2
(no subject)
...i am sure, there is a clear way how to do it, no?
#shouldn't i actually get more or less the same parameterestimates with both
#methods?
library(stats4)
> ll<-function(alfa,beta)
+ {n<-24
+ x<-data2
+ -n*log(alfa)-n*log(beta)+alfa*sum(x^beta)-(beta-1)*sum(log(x))}
> est<-mle(minuslog=ll, start=list(alfa=10, beta=1))
There were 50 or more warnings (use warnings() to see the first 50)
> summary(est)
Maximum likelihood estimation
Call:
mle(minuslogl = ll, start = list(alfa = 10, beta = 1))
Coefficients:
Estimate Std. Error
alfa 0.002530163 0.0006828505
beta 0.641873...
2007 Sep 10
1
MLE Function
...39;\n' or ';' or '}' in "ll<-function(lambda,alfa){n<-200;x<-x.gam -n*alfa*log(lambda)+n*log(gamma(alfa))-9alfa"
> ll<-function(lambda,alfa){n<-200;x<-x.gam -n*alfa*log(lambda)+n*log(gamma(alfa))-(alfa-1)*sum(log(x))+lambda*sum(x)}
> est<-mle(minuslog=ll,start=list(lambda=2,alfa=1))
Error in optim(start, f, method = method, hessian = TRUE, ...) :
objective function in optim evaluates to length 200 not 1
audaces fortuna iuvat
---------------------------------
[[alternative HTML version deleted]]
2006 Dec 30
3
wrapping mle()
Hi,
How can we set the environment for the minuslog function in mle()? The
call in this code fails because the "ll" function cannot find the object
'y'. Modifying from the example in ?mle:
library(stats4)
ll <- function(ymax=15, xhalf=6) {
-sum(stats::dpois(y, lambda=ymax/(1+x/xhalf), log=TRUE))
}
fit.mle <- function(...
2005 Sep 06
2
fitting distributions with R
...ates?How do you choose the starting values? in
my opinion it should be around 1/mean(data).
#Parameterestimation ??with mle() with the log-likelihood funktion of the ??
#exponentialdistribution
library(stats4)
ll<-function(beta)
{n<-24
x<-data2
-n*log(beta)+beta*sum(x)}
est<-mle(minuslog=ll, start=list(beta=0.1))
summary(est)
#instead of a result, i get:
Error in optim(start, f, method = method, hessian = TRUE, ...) :
?? ?? ?? ?? non-finite finite-difference value [1]
In addition: There were 50 or more warnings (use warnings() to see the first
50)
#with fitdistr() for the expo...
2007 Sep 11
1
Fitting Data to a Noncentral Chi-Squared Distribution using MLE
...it some data I have (called ONES20) to the non-central chi-squared distribution.
>library(stats4)
>ll<-function(lambda,k){x<-ONES20; 25573*0.5*lambda-25573*log(2)-sum(-x/2)-log((x/lambda)^(0.25*k-0.5))-log(besselI(sqrt(lambda*x),0.5*k-1,expon.scaled=FALSE))}
> est<-mle(minuslog=ll,start=list(lambda=0.05,k=0.006))
R accepts the function definition without a problem, but gives this error when I ask for the mle of the parameters.
Error in besselI(x, nu, 1 + as.logical(expon.scaled)) :
Non-numeric argument to mathematical function
In addition: Warning messa...
2011 Feb 25
0
Fitting distribution in range
...{dgamma(y, shape=a, rate=b)}
integ_res <- tryCatch({integrate(integrand,min_x,max_x)$value},
error=function(err){0});
if (integ_res == 0) { return(NA) }
C = 1 / integ_res
res = -(sum(log(C*dgamma(x,shape=a,rate=b))))
return(res)
}
m <- mean(x)
v <- var(x)
fit <- mle(minuslog=ll_gamma,start=list(a=m^2/v,b=m/v))
Now, for some reason I get very weird results. I have tested it by sampling
random numbers from gamma distribution, for example, and then try to fit it
with the algorithm I wrote.
Am I doing something wrong? do I need to first fit the sample with regular
gamma...
2013 Apr 10
0
mle function
...ting the code below, I just obtain the result for t=1.
################
library(stats4)
likelihood <- function(v1,v2,v3){
for (t in 1:136){
return(-(sum(E1_f[t,]*(v1*teta1[] + v2*teta2[] + v3*teta3[]) -
E_f[t,]*log(1 + exp(v1*teta1[] + v2*teta2[] + v3*teta3[])))))
}
}
L_f <- mle(minuslog=likelihood, start=list(v1=1, v2=2, v3=3))
x <- summary(L_f)
################
What should I change in the code?
And how can I store the values of v1(t), v2(t) and v3(t) in 3 vectors,
in order to use them after?
Thank you very much.
Roger
2009 Oct 26
0
MLE for noncentral t distribution
...; > >>> ll<-function(lambda,alfa) {n<-200
> > >>> x<-x.gam
> > >>> -n*alfa*log(lambda)+n*log(gamma(alfa))-(alfa-
> > >>> 1)*sum(log(x))+lambda*sum(x)} ## -log-likelihood function
> > >>> est<-mle(minuslog=ll, start=list(lambda=2,alfa=1))
> > >>>
> > >>> Is anyone how how to write down -log-likelihood function for
> noncentral t
> > >>> distribution?
> > >>
> > >> Just use dt. E.g.
> > >>
>...