# NOT RUN {
## Examples following a successful fit
data(SpotVA1)
vb1 <- vbFuns()
fit1 <- nls(tl~vb1(age,Linf,K,t0),data=SpotVA1,start=list(Linf=12,K=0.3,t0=0))
plot(tl~age,data=SpotVA1,pch=21,bg="gray40")
nlsTracePlot(fit1,vb1,legend="bottomright")
data(CodNorwegian)
r1 <- srFuns("Ricker")
fitSR1 <- nls(log(recruits)~log(r1(stock,a,b)),data=CodNorwegian,start=list(a=3,b=0.03))
plot(recruits~stock,data=CodNorwegian,pch=21,bg="gray40",xlim=c(0,200))
nlsTracePlot(fitSR1,r1)
# no plot, but returns trace results as a matrix
( tmp <- nlsTracePlot(fitSR1,r1,add=FALSE) )
# }
# NOT RUN {
if (require(FSAdata)) {
data(BSkateGB)
wtr <- filterD(BSkateGB,season=="winter")
bh1 <- srFuns()
trc <- capture.output(try(
fitSR1 <- nls(recruits~bh1(spawners,a,b),wtr,
start=srStarts(recruits~spawners,data=wtr),trace=TRUE)
))
plot(recruits~spawners,data=wtr,pch=21,bg="gray40")
nlsTracePlot(trc,bh1)
# zoom in on y-axis
plot(recruits~spawners,data=wtr,pch=21,bg="gray40",ylim=c(0.02,0.05))
nlsTracePlot(trc,bh1,legend="top")
# return just the trace results
( tmp <- nlsTracePlot(trc,bh1,add=FALSE) )
}
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab