similar to: understanding nlm

Displaying 20 results from an estimated 7000 matches similar to: "understanding nlm"

2006 Apr 06
3
skipping rows in trellis key
Hi, I would like to add a key to my trellis plot using draw.key. Here is what I want: 3 x 6 key where the first row is a header. row 1: empty, "S-R Mapping", "R^2" row 2: pch=17, "Color", 0.951 row 2: pch=17, "Shape", 0.934 ect... The problem is that I would like the cell in the upper left corner to be empty (a placeholder) with the remaining
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 >
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
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 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)))
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 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
2007 Sep 16
1
Problem with nlm() function.
In the course of revising a paper I have had occasion to attempt to maximize a rather complicated log likelihood using the function nlm(). This is at the demand of a referee who claims that this will work better than my proposed use of a home- grown implementation of the Levenberg-Marquardt algorithm. I have run into serious hiccups in attempting to apply nlm(). If I provide gradient and
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
2011 Aug 24
1
problema de selección de valores iniciales en nlm
Hola a todos, Necesito estimar dos parametros utilizando la función nlm; fit<-nlm(hood2par,c(x01[i],x02[j]),iterlim=300, catch=x[,c(3,4,5)],sp=.5) donde hood2par es una logística modificada. Pero en mi caso, la convergencia de nlm depende de los valores iniciales de dichos parámetros. Para buscar dichos valores iniciales de manera automática, genero dos vectores de valores iniciales
2012 Nov 30
2
NA return to NLM routine
Hello, I am trying to understand a small quirk I came across in R. The following code results in an error: k <- c(2, 1, 1, 5, 5) f <- c(1, 1, 1, 3, 2) loglikelihood <- function(theta,k,f){ if( theta<1 && theta>0 ) return(-1*sum(log(choose(k,f))+f*log(theta)+(k-f)*log(1-theta))) return(NA) } nlm(loglikelihood ,0.5, k, f ) Running this code results in: Error
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)) :
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 {
1999 Dec 09
1
nlm() problem or MLE problem?
I am trying to do a MLE fit of the weibull to some data, which I attach. fitweibull<-function() { rt<-scan("r/rt/data2/triam1.dat") rt<-sort(rt) plot(rt,ppoints(rt)) a<-9 b<-.27 fn<-function(p) -sum( log(dweibull(rt,p[1],p[2])) ) cat("starting -log like=",fn(c(a,b)),"\n") out<-nlm(fn,p=c(a,b), hessian=TRUE)
2003 Oct 17
2
nlm, hessian, and derivatives in obj function?
I've been working on a new package and I have a few questions regarding the behaviour of the nlm function. I've been (for better or worse) using the nlm function to fit a linear model without suppling the hessian or gradient attributes in the objective function. I'm curious as to why the nlm requires 31 iterations (for the linear model), and then it doesn't work when I try to add
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
2003 Sep 30
1
can't get names from vector in nlm calls
I've been trying to figure out how to get the names of the parameter vector variables when inside the function that nlm calls to return the objective function value: knls <- function( theta, eqns, data, fitmethod="OLS", instr=NULL, S=NULL ) { ## print( names( theta ) ) # returns NULL ## get the values of the parameters for( i in 1:length( theta ) )
2003 Jul 08
2
specifying multiple parameter starting values in nlm
Hi there I am having trouble figuring out how to get an nlm function to report estimates for two parameter values in an estimation. The way I've got it goes something like this: f <- function (q, r) { here, I have a second loop which uses q, r to give me values for c, d below. a and b are already specified; this loop is a mass-balance function where I am trying to find values of q,
2011 Apr 23
2
Could I use R function lm or nlm in C code?
Dear R, I'm doing some simulation work and it takes me a lot of time to do it in R. So I try to implement it in C code, but I want to use some R functions directly for my lazy and the robustness of code. For example, I will use lm and nlm in my program. How could I use R's lm and nlm function directly? I thinks these functions are not included in the R's include directory. Do I need