[R] nls convergence trouble

Christian Ritz ritz at life.ku.dk
Thu Sep 4 15:26:17 CEST 2008


Hi Benoit,

another way of making Petr's point is by looking at the profile log likelihood function
for b; that is, only estimating the a parameter for a grid of b values:


## Defining mean function for fixed b
lgma <- function(b){

    function(C0, m, V, a){ (V + b * m * a + C0 * V * b - ((C0 * V * b)^2 + 2 * C0 *
    b * V^2 - 2 * C0 * V * m * a * b^2 + V^2 + 2 * V * m * a *
    b + (b * m * a)^2)^(1/2))/(2 * b * m)}

}

## Defining profile log likelihood function
logLikb <- function(b)
{
    logLik(nls(Qe~(lgma(b))(C0, m, V, a),data = bois.DATA,start = list(a=300)))
}
logLikb2 <- Vectorize(logLikb, "b")  # vectorising the function

## Plotting the profile function
plot(x<-10^(seq(-4, 0, length.out=50)), logLikb2(x), type="l")


Essentially any b value from 0.2 upwards results in the same model fit.

Christian



More information about the R-help mailing list