[R] term.formula error when updating an nls object

Ken Knoblauch ken.knoblauch at inserm.fr
Wed Jan 27 11:10:38 CET 2010


Hi,

I'm getting an error that I don't understand when updating an nls
object.  Here is a toy example.

dd <- structure(list(Contrast = c(0.00376, 0.03759, 0.12782, 0.25564,
0.50376, 1), Response = c(0.29915, 6.13248, 29.01709, 30.0641,
29.46581, 27.67094)), .Names = c("Contrast", "Response"), class =  
"data.frame", row.names = c(NA,
-6L))

m1 <- nls(Response ~
			Rm * Contrast^ex/(Contrast^ex + sig^ex),
			data = dd,
			start = list(Rm = 30, sig = 0.05, ex = 3))

m2 <- update(m1, . ~
			Rm * Contrast^ex/(Contrast^fx + sig^fx),
			start = list(Rm = 30, sig = 0.05, ex = 3,
			fx = 3.1))
Error in terms.formula(tmp, simplify = TRUE) : invalid power in formula

but there is nothing wrong with fitting the second model directly
with nls

m2a	<- nls(Response ~
			Rm * Contrast^ex/(Contrast^fx + sig^fx),
			data = dd,
			start = list(Rm = 30, sig = 0.05, ex = 3,
			fx = 3.1))


nor with fitting the model with the data transformed (though it is
not necessarily the way I would like to fit the model in this
case).

m2b <- update(m1, log(.) ~ log(.))
m3 <- update(m2b, . ~
	log(Rm * Contrast^ex/(Contrast^fx + sig^fx)),
	start = list(Rm = 30, sig = 0.05, ex = 3,
			fx = 3.1))

sessionInfo()
R version 2.10.1 Patched (2010-01-25 r51051)
i386-apple-darwin9.8.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods
[7] base

Thanks, in advance, for any help.

Ken

-- 
Ken Knoblauch
Inserm U846
Stem-cell and Brain Research Institute
Department of Integrative Neurosciences
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.sbri.fr/members/kenneth-knoblauch.html



More information about the R-help mailing list