Displaying 20 results from an estimated 1400 matches similar to: "Gradient problem in nlm"
2006 Sep 26
1
warning message in nlm
Dear R-users,
I am trying to find the MLEs for a loglikelihood function (loglikcs39) and
tried using both optim and nlm.
fredcs39<-function(b1,b2,x){return(exp(b1+b2*x))}
loglikcs39<-function(theta,len){
sum(mcs39[1:len]*fredcs39(theta[1],theta[2],c(8:(7+len))) - pcs39[1:len] *
log(fredcs39(theta[1],theta[2],c(8:(7+len)))))
}
theta.start<-c(0.1,0.1)
1. The output from using optim is
1999 Nov 24
0
nlm gradient and hessian
Out of curiosity, I have tried, without success, to use the new
facility in nlm to specify the gradient and hessian. (It is many years
since I had a problem simple enough to make analytic derivation of
these worthwhile.) The help now says that the function must have
attributes with these names but gives no indication as to what should
be in the attributes. The online example and demo do not use
2003 Nov 17
0
gradient option in 'nlm' function
<FONT face="Default Sans Serif, Verdana, Arial, Helvetica, sans-serif" size=2><DIV>Dear list members,</DIV><DIV> </DIV><DIV>I am trying to use "nlm" function to maximize a mixture likelihood of beta densities. There are five unknown parameters in the likelihood. Since I can get the analytic gradient, I attach the "gradient"
2006 Jun 19
0
help on nlm (gradient) (fwd)
Hello
No worries anymore. Figured it out.
Thanks for everything.
Luz
---------- Forwarded message ----------
Date: Sun, 18 Jun 2006 23:12:25 -0600 (MDT)
From: Luz Maria Palacios Derflingher <palacios at math.ucalgary.ca>
To: r-help at lists.R-project.org
Cc: r-help at stat.math.ethz.ch.
Subject: help on nlm (gradient)
Hello.
I am having some trouble using nlm in R for windows version
1997 Nov 21
2
R-alpha: nlm and gradients
At present the documentation for nlm refers the reader to Dennis and
Schnabel for details on the algorithms. It also states that the
function is liable to change.
Can anyone tell me if the current version of nlm uses only function
values or if it can use gradients and Hessians when they are
available? I would like to get an idea of how difficult it would be
to port the development versions of
2010 Jun 15
1
Error in nlm : non-finite value supplied by 'nlm'
Hello,
I am trying to compute MLE for non-Gaussian AR(1). The error term follows a difference poisson distribution. This distribution has one parameter (vector[2]).
So in total I want to estimate two parameters: the AR(1) paramter (vector[1]) and the distribution parameter.
My function is the negative loglikelihood derived from a mixing operator.
f=function(vector)
2008 Mar 19
0
Error en nlm(logdgenexpn, p = c(vmomest[[1]], vmomest[[2]]), x = x.genexp, : valor no finito provisto por 'nlm'
Dear useRs,
I am analysing the behaviour of MLE for the two parameters of a kind
of exponential distribution, leaving as initial values the estimators
moments produced by the variation coefficient.
I do using simulations, giving them an accountant, r. But running my
codes remains a problem with the nlm function. To review details
wearing
On one of the lines put status
2003 Oct 24
1
first value from nlm (non-finite value supplied by nlm)
Dear expeRts,
first of all I'd like to thank you for the
quick help on my last which() problem.
Here is another one I could not tackle:
I have data on an absorption measurement which I want to fit
with an voigt profile:
fn.1 <- function(p){
for (i1 in ilong){
ff <- f[i1]
ex[i1] <- exp(S*n*L*voigt(u,v,ff,p[1],p[2],p[3])[[1]])
}
sum((t-ex)^2)
}
out <-
2009 Feb 19
2
Source code for nlm()
Hi,
Where can I find the source code for nlm()? I dowloaded the R2.8.1.tar.gz
file and looked at all the .c and .f files, but couldn't find either nlm.c
or nlm.f
There is an nlm.r file, but that is not useful.
Thanks for any help,
Ravi.
----------------------------------------------------------------------------
-------
Ravi Varadhan, Ph.D.
Assistant Professor, The Center on Aging
2008 May 22
1
Computing Maximum Loglikelihood With "nlm" Problem
Hi,
I tried to compute maximum likelihood under gamma distribution,
using nlm function. The code is this:
__BEGIN__
vsamples<- c(103.9, 88.5, 242.9, 206.6, 175.7, 164.4)
mlogl <- function(alpha, x) {
if (length(alpha) > 1) stop("alpha must be scalar")
if (alpha <= 0) stop("alpha must be positive")
return(- sum(dgamma(x, shape = alpha, log = TRUE)))
2012 Oct 19
2
likelihood function involving integration, error in nlm
Dear R users,
I am trying to find the mle that involves integration.
I am using the following code and get an error when I use the nlm function
d<-matrix(c(1,1,0,0,0,0,0,0,2,1,0,0,1,1,0,1,2,2,1,0),nrow=10,ncol=2)
h<-matrix(runif(20,0,1),10)
integ<-matrix(c(0),nrow=10, ncol=2)
ll<-function(p){
for (k in 1:2){
for(s in 1:10){
integrand<-function(x)
2008 Jun 03
1
nlm behaviour and error
Hi R-Gurus,
I've been cutting along quite nicely with nlm, until
I threw in the following condition in the function that nlm is
minimising:
if (((term*bexp) < 0.0001)) {
#warning(term*bexp, "=term*bexp",psi,"=psi")
theta<-2000
}
Now when I run this function anywhere else, there is no problem, whether
or the if's condition is met.
When
2003 Sep 01
3
error message in nlm()
Hi all,
I have been trying the nlm function but received an error message
which reads:
Error in nlm(intensities ~ f, c(epsilon.spec.start,
epsilon.unspec.start, :
invalid function value in 'nlm' optimizer
The message is generated somewhere in the compiled part, apparently
within the function
static void fcn(int n, const double x[], double *f, function_info
*state)
where a jump
2004 Oct 12
2
constrained optimization using nlm/optim?
I'm looking for an example of a simple R script that impliments a
contrained nonlinear function using nlm or optim. I'm not exactly sure how
to impliment the constraints within the objective function that is passed
to nlm/optim.
obj.func <- function( p ) {
x(p) <- unconstrained obj function value
if( constraint1 > something ) {
obj.func <- x(p)
} else {
2006 Mar 31
1
andersen plot vs score process or scaled Schoenfeld residuals to test for proporti0nal hazards
Dear all,
I use the Andersen plot to check for proportional hazards assumption for a
factor (say x) in the Cox regression model and obtained a straight line that
pass through the origin. However, the formal test done by the R-function
cox.zph, which is based on the plot of Schonefeld residuals against time,
indicates that proportional hazards assumption is violated. Further, a plot
of the score
1999 Sep 29
1
nlm recursion problem
Hi
I am trying to use nlm with an additional call to nlm within the function
but after the first pass, the parameters to the outer call are being
passed to the inner call. The inner call is a very trivial problem.
ie:
test.outer<-function(param.outer){
slope<-nlm(test.inner,param.inner)
...
loglikelihood<-sum(...)
return(-loglikelihood)
}
and
nlm(test.outer,param.outer)
on the
2004 Oct 11
1
Puzzled on nlm
Dear R People:
Here is a function to minimized:
>mfun1
function(x,a) {
x[1] <- a[1]*x[2] + a[3] - a[2]*(a[1]-a[2])*a[3]
x[2] <- a[1]*x[1] - a[2]*a[3]
return(x)
}
Here is my first try:
>nlm(mfun1,c(1,1))
Error in f(x, ...) : Argument "a" is missing, with no default
>
>nlm(mfun1,c(1,1),a=c(0.8,0.5,1))
Error in nlm(mfun1, c(1, 1), a = c(0.8, 0.5, 1)) :
1997 Jun 06
1
R-beta: nlm
I am trying to use the function "nlm" to find the mle. I want to use a
generic function for the likelihood which would require me to use both the
parameters and the data as arguments. But nlm requires the function to
have only the parameters as arguments for this function (see example below).
> testfun <- function(x,y) sum((x-y)^2) # x - parameters, y - data
>
2008 Oct 14
0
nlm return wrong function value - garch fitting
I am using nlm to maximize a likelihood function. When I call the likelihood
function (garchLLH) via nlm however, nlm returns the wrong value of the
function.
When I test the likelihood function manually I get the correct answer. I'm
probably doing something really stupid, maybe someone can point it out for
me.
###############this is the function i am trying to minimize ############
2003 Jan 06
1
On nlm
Dear all, I have to minimize a (real) function in a loop (say i in
(1:1000)) and store its ``$estimate'', via
l2estim<-nlm(f.minimo,c(-.01,0.1))$estimate
into a vector for further analisys.
Since the function's behaviour is quite peculiar (in the sense that in
the simulation study it may not have a minumum), sometimes I get the the
warning
Error in nlm(minimo, c(-0.01, 0.1),