[R] Regression and fitting

Gunther Höning gunther.hoening at ukmainz.de
Tue Jul 1 14:40:44 CEST 2008


Dear list,

I have some values like
Time	2	4		8		24		48	72

UTR	82543	169105	207615	96633		31988	7005
UTRs	82687	172934	205541	101842	31898	6950
of a twice repeated meassurement.

I know that the underlying function is of :

f(x) =  SO/(sqrt(2*pi)*sigma *x) * exp(-(S0*ln x - mu)^2/(2*sigma^2)).

How can I determine the value of S0, sigma and mu.

I tried nls:

lognormal <- function(x,S0,sigma,mu) {S0/(sqrt(2*pi)*sigma *x) *
exp(-(S0*log (x) - mu)^2/(2*sigma^2))}
x <- rep(c(2,4,6,24,48,72),2)
y <-
c(82543,169105,207615,96633,31988,7005,82687,172934,205541,101842,31898,6950
)
dat <- data.frame(x,y)
regfit <-  nls(y ~ lognormal(x,S0,sigma,mu) ,data =dat)


Output:

Error in nlsModel(formula, mf, start, wts) : 
        singular gradient matrix at initial parameter estimates
Warning message:
No starting values specified for some parameters.
Intializing 'S0', 'sigma', 'mu' to '1.'.
Consider specifying 'start' or using a selfStart model in: nls(y ~
lognormal(x, S0, sigma, mu), data = dat) 

Can anybody help on this topic please ?


Gunther



More information about the R-help mailing list