[R] nls

Douglas Bates bates at stat.wisc.edu
Wed Feb 19 15:35:03 CET 2003


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