ydat<-c(5.308, 7.24, 9.638, 12.866, 17.069, 23.192, 31.443,
38.558, 50.156, 62.948, 75.995, 91.972) # for testing
y<-ydat # for testing
tdat<-1:length(ydat) # for testing
# WARNING -- using T can get confusion with TRUE
t<-tdat
start1<-c(b1=1, b2=1, b3=1)
eunsc<- y ~ b1/(1+b2*exp(-b3*t))
an1<-try(nls(eunsc, start=start1, trace=TRUE))
print(an1)
cat("GLOBAL DATA
")
an1q<-try(nlsmnq(eunsc, start=start1, trace=TRUE))
print(an1q)
rm(y, t)
cat("LOCAL DATA
")
ydata1<-data.frame(y=ydat, t=tdat)
ydata2<-data.frame(y=1.5*ydat, t=tdat)
an1ql1<-try(nlsmnq(eunsc, start=start1, trace=TRUE, data=ydata1))
print(an1ql1)
an1ql2<-try(nlsmnq(eunsc, start=start1, trace=TRUE, data=ydata2))
print(an1ql2)
cat("GLOBAL DATA AGAIN -- should fail due to no data
")
an1q<-try(nlsmnq(eunsc, start=start1, trace=TRUE))
print(an1q)
Run the code above in your browser using DataLab