[R] nls fitting problems (singularity)
Karl Knoblick
karlknoblich at yahoo.de
Wed Jun 30 01:55:47 CEST 2004
Hallo!
I have a problem with fitting data with nls. The first
example with y1 (data frame df1) shows an error, the
second works fine.
Is there a possibility to get a fit (e.g. JMP can fit
also data I can not manage to fit with R). Sometimes I
also got an error singularity with starting
parameters.
# x-values
x<-c(-1,5,8,11,13,15,16,17,18,19,21,22)
# y1-values (first data set)
y1=c(-55,-22,-13,-11,-9.7,-1.4,-0.22,5.3,8.5,10,14,20)
# y2-values (second data set)
y2=c(-92,-42,-15,1.3,2.7,8.7,9.7,13,11,19,18,22)
# data frames
df1<-data.frame(x=x, y=y1)
df2<-data.frame(x=x, y=y2)
# start list for parameters
sl<-list( d=0, b=10, c1=90, c2=20)
# y1-Analysis - Result: Error in ... singular
gradient
nls(y~d+(x-b)*c1*(x-b<0)+(x-b)*c2*(x-b>=0), data=df1,
start=sl)
# y2-Analysis - Result: working...
nls(y~d+(x-b)*c1*(x-b<0)+(x-b)*c2*(x-b>=0), data=df2,
start=sl)
# plots to look at data
par(mfrow=c(1,2))
plot(df1$x,df1$y)
plot(df2$x,df2$y)
Perhaps there is another fitting routine? Can anybody
help?
Best wishes,
Karl
___________________________________________________________
Bestellen Sie Y! DSL und erhalten Sie die AVM "FritzBox SL" für 0.
Sie sparen 119 und bekommen 2 Monate Grundgebührbefreiung.
More information about the R-help
mailing list