Displaying 5 results from an estimated 5 matches for "negll".
Did you mean:
negl
2007 Feb 17
1
Constraint maximum (likelihood) using nlm
...ng to find the maximum (likelihood) of a function. Therefore,
I'm trying to minimize the negative likelihood function:
# params: vector containing values of mu and sigma
# params[1] - mu, params[2]- sigma
# dat: matrix of data pairs y_i and s_i
# dat[,1] - column of y_i , dat[,2] column of s_i
negll <- function(params,dat,constant=0)
{
for(i in 1:length(dat[,1]))
{
llsum <- log( params[2]^2 + dat[i,2]^2) +
(( dat[i,1] - params[1])^2/ (params[2]^2 + dat[i,2]^2))
}
ll <- -0.5 * llsum + constant
return(-ll)
}
Using (find data attached):
data.osl <- read.table("osl.dat&...
2005 Sep 29
1
Error using a data frame as the "start" parameter in mle()
Dear R-Users,
I am trying to use mle() to optimize two (or more) parameters, but I want
to specify those parmeters in a data frame rather than having to spell
them out separately in the "start" variable of mle().
My call is
> mle(negll, start=list(aps=init), fixed=list(measphot=newphot,
formod=formod, Nbands=Nbands), method="BFGS")
where negll is a function I have written which uses the function
predict.loess(). negll works fine when called directly. The parameter I am
trying to optimize, "aps", is a data...
2011 Aug 17
2
An example of very slow computation
...t;-kvec[1]
k2<-kvec[2]
k3<-kvec[3]
# MIN problem terbuthylazene disappearance
z<-k1+k2+k3
y<-z*z-4*k1*k3
l1<-0.5*(-z+sqrt(y))
l2<-0.5*(-z-sqrt(y))
val<-100*(1-((k1+k2+l2)*exp(l2*t)-(k1+k2+l1)*exp(l1*t))/(l2-l1))
} # val should be a vector if t is a vector
negll <- function(theta){
# non expm version JN 110731
pred<-Mpred(theta)
sigma<-exp(theta[4])
-sum(dnorm(dat[,2],mean=pred,sd=sigma, log=TRUE))
}
theta<-rep(-2,4)
fand<-nlogL(theta)
fsim<-negll(theta)
cat("Check fn vals: expm =",fand," simple=",fsim,"...
2007 Dec 11
1
R computing speed
...trics, Academic Press.
multilogit.c <- function(y, xi, xi.names = colnames(xi), c.base=1,
rest=NULL, w = rep(1,nrow(y)), method='BFGS')
{
n.obs <- sum(w)
xi<-cbind(1,xi)
colnames(xi)[1]<-"Intercept"
nx<-ncol(xi)
ny<-ncol(y)
beta<-numeric(nx*ny)
negll<- function(beta,y,xi)
{
beta[rest]<-0
beta[(((c.base-1)*nx)+1):(c.base*nx)]<-0
lli <- y * (xi%*%matrix(beta,nx,ny) - log ( apply(exp(
xi%*%matrix(beta,nx,ny)) ,1,sum ) ) )
lli<-lli*w
-sum(lli)
}
pi<- apply((y*w),2,mean)/mean(w)
ll0 <- (t(pi)%*%log(pi))*sum(w)...
2007 Jun 26
2
fisher information matrix
Hi All,
a colleague wants to calculate the Fisher information matrix for a model he
wrote (not in R). He can easily get the neg-log-likelihood and the best fit
parameters at the minimum. He can also get negLLs for other parameter values too.
Given these data, is there a way in R to calculate the Fisher information matrix?
Best,
Federico
--
Federico C. F. Calboli
Department of Epidemiology and Public Health
Imperial College, St Mary's Campus
Norfolk Place, London W2 1PG
Tel +44 (0)20 7594 1602...