[R] nls

Komanduru Sai C sck2348 at cacs.louisiana.edu
Thu Mar 27 00:41:46 CET 2003


Hi,

 df <- read.table("data.txt", header=T);						
 library(nls);
 fm <- nls(y ~ a*(x+d)^(-b), df, start=list(a=max(df->y,na.rm=T)/2,b=1,d=0));

 I was using the following routine which was giving Singular Gradient, Error in 
numericDeriv(form[[3]], names(ind), env) : 
        Missing value or an Infinity produced when evaluating the model errors.
        

I also tried the below method given by Dr. Dougla Bates. But still am getting 
the error.
 Error in numericDeriv(form[[3]], names(ind), env) : 
        Missing value or an Infinity produced when evaluating the model


 df <- read.table("data.txt", header=T);						
 df1 = na.omit(df[, 1:2])
 library(nls);
 fm = nls(y ~ (x+d)^(-exp(lb)), data = df1, start=c(lb = 0, d = 0),alg = 
'plinear', trace = TRUE);




  I would be glad if someone can help me.

Thanks & Regards,
Sai Charan Komanduru

>To: Komanduru Sai C <sck2348 at cacs.louisiana.edu>
>Cc: r-help at stat.math.ethz.ch
>Subject: Re: [R] nls
>From: Douglas Bates <bates at stat.wisc.edu>
>Date: 19 Feb 2003 08:33:52 -0600
>User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Common Lisp)
>MIME-Version: 1.0
>X-Keywords: 
>
>Komanduru Sai C <sck2348 at cacs.louisiana.edu> writes:
>
>> Hi,
>> 
>> I am using nls library
>> 
>> df <- read.table("data.txt", header=T);						
>> library(nls);
>> fm <- nls(y ~ a*(x+d)^(-b), df, start=list(a=max(df->y,na.rm=T)/2,b=1,d=0));
>> coef(fm); 
>> q();
>
>1) Are you sure you meant max(df->y, na.rm=TRUE) and not 
>   max(df$y, na.rm=TRUE)? 
>
>2) To begin you may want to use a data frame without the missing data
>   df1 = na.omit(df[, 1:2])
>
>3) Use the plinear algorithm and change from b to exp(lb)
>
>   fm = nls(y ~ (x+d)^(-exp(lb)), data = df1, start=c(lb = 0, d = 0),
>            alg = 'plinear', trace = TRUE)
>
>-- 
>Douglas Bates                            bates at stat.wisc.edu
>Statistics Department                    608/262-2598
>University of Wisconsin - Madison        http://www.stat.wisc.edu/~bates/



More information about the R-help mailing list