Skip to content

update method for nls

1 message · Ken Knoblauch

#
Would it be useful to have an update method for nls?
I learned recently that the default method can generate an error unless
the rhs of a formula is protected by being wrapped in
a function, such as log or I(), when terms.formula is called.

https://stat.ethz.ch/pipermail/r-help/2010-January/225822.html

https://stat.ethz.ch/pipermail/r-help/2010-January/225837.html

Would the following be a useful way to ensure this?

update.nls <- function(object, formula, ...){
	formula <- if(!missing(formula)){
	  tmp <- formula[[3]]
	  formula[[3]] <- as.call(list(as.name("I"), as.call(tmp)))
	  formula
	}
	NextMethod("update", ...)
}

Ken