I am trying to fit a logistic model to my 10 year data (1999-2008) by year.  
Codes like below:

Year <- c(1999: 2008)
for(y in 1:length(year)) {
        file.input <- paste("C:\\", year[y], "\\data.csv", sep="")
table <- read.csv(file=fileinput, header=TRUE, as.is=TRUE, na.strings=c(""))
        initial <- getInitial(percent ~ SSlogis(age, Asym, xmid, scal), data = 
table)
fm1 <- nls(percent ~ SSlogis(age, Asym, xmid, scal), data = table)
        summary <- summary(fm1)
        parameters <- summary$parameters
        file.output <- paste("C:\\", year[y], "\\parameters.csv", sep="")
        write.csv(parameters, file=file.output, row.names=FALSE)
}

However, when one of 10 years can't be converged, such as 2000, the loop stops 
in that year (2000) even though the rest years (2001 to 2008) can be converged. 
I would really appreciate if someone helps me on how to force the loop function 
to finish all 10 rounds even when errors occur due to no convergences for some 
of years.


Hongsheng (Hank) Liao
Lab Manager
Center for Quantitative Fisheries Ecology
Old Dominion University
Phone: 757-683-4571




        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to