[R] Problems using NLS in conjunction with non-parameteric bootstrapping

mweckel mweckel at mianus.org
Sat Mar 19 21:24:15 CET 2011


Hello,

I have been successfully using nls to fit a non-linear, self-limiting
function to several sets of data collected in 2010 (example found below). 
To generate confidence intervals for parameter estimates, I've been
attempting to bootstrap my sample. Unfortunately, I have meet with
singularity gradients and failures to converge. I have altered maxiter and
minFactor statements, used several different starting parameters, and the
plinear and port algorithm to no avail.  I used this same approach on a 2009
data set with no problems. 

I'm assuming that one or more of my bootstrap samples is causing the
problem. If this is the case, are there any suggestions on how I can proceed
with bootstrapping to generate CI? 


Thank you in advance,
Mark 

y <- c(3.46,1.00,2.0,2.23,4.24,1.00,4.58,
4.69,3.00,5.10,2.83,3.46,1.73,2.46,1.41,2.24,3.00,1.73)
x <- c(0.39,0.05,0.10,0.20,0.53,0.17,0.61,
0.40,0.30,0.40,0.42,0.35,0.28,0.40,0.12,0.25,0.71,0.15)

mydata <- data.frame(x,y)
names(mydata) <- c("x","y") # variable names 

%x=Trap success; proportion of total trap nights where at least one deer was
photographed
%y=Square root transformation of total number of deer photographed 


#asymptotic equation y = (a*x)/(b+x)
NlMFunc1 <- function(x, a, b) {(a*x)/(b+x)}
NlMFunc1 <- nls(y ~ NlMFunc1(x, alpha, beta), 
data = RPOvTS, start = list(alpha = 10, beta = 1), control = list(maxiter =
10000, minFactor=1/20048), 
trace = T)
summary(NlMFunc1)
logLik(NlMFunc1)


#Generate non-parametric bootstrap estimates of alpha and beta
#using bootstrapping 
################################################

BootF=function (data,i){
	# take a random sample of size 18 from a SqRtFemPhoto
	# sample with replacement
	d <- data[i,]
   	NlmResampF<- function(x, a, b) {(a*x)/(b+x)}
	NlmResampF <- nls(y ~ NlmResampF (x, alpha, beta), 
	data = d, start = list(alpha = 10, beta = 1),
	control = list(maxiter = 10000, minFactor=1/20048, 
	trace = T))

 	c(logLik(NlmResampF ), coef(NlmResampF )) }
	#summary(NlmResampF )
	#logLik(NlmResampF )


library(boot)	
Female.boot<-boot(data=mydata, statistic=BootF,
R=1000)
Female.boot$t 

--
View this message in context: http://r.789695.n4.nabble.com/Problems-using-NLS-in-conjunction-with-non-parameteric-bootstrapping-tp3390208p3390208.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list