if( !require('investr') ){ install.packages('investr', dependencies=TRUE, repos='http://cran.rstudio.com/') } library(investr) # has the function plotFit # # btb data: # load(file='../../BookCode/nlrwr/data/btb.rda') plot(btb$x, btb$y, xlab='x', ylab='y') grid() btb.m1 = nls(y ~ theta1 + (theta2 - theta1)^(theta3 + 1) / (x - theta1)^theta3, data=btb, start=list(theta1=2, theta2=4, theta3=1), trace=FALSE) print(summary(btb.m1)) #postscript("../../WriteUp/Graphics/Chapter3/chap_3_prob_1_btb.eps", onefile=FALSE, horizontal=FALSE) plotFit(btb.m1, main='btb data and fit') grid() #dev.off() # # sts data: # load(file='../../BookCode/nlrwr/data/sts.rda') plot(sts$x, sts$y, xlab='x', ylab='y') grid() sts.m1 = nls(y ~ theta1 + (theta2 - theta1)^(theta3 + 1) / (x - theta1)^theta3, data=sts, start=list(theta1=2, theta2=4, theta3=1), trace=FALSE) print(summary(sts.m1)) #postscript("../../WriteUp/Graphics/Chapter3/chap_3_prob_1_sts.eps", onefile=FALSE, horizontal=FALSE) plotFit(sts.m1, main='sts data and fit') grid() #dev.off()