[R] How can I 'predict' from an nls model with a fit specified for separate groups?

Stuart Rosen stuart at phonetics.ucl.ac.uk
Wed Apr 20 17:04:31 CEST 2011


Following an example on p 111 in 'Nonlinear Regression with R' by Ritz & 
Streibig, I have been fitting nls models using square brackets with the 
grouping variable inside. In their book is this example, in which 
'state' is a factor indicating whether a treatment has been used or not:

 > Puromycin.m1 <- nls(rate ~ Vm[state] *
+ conc/(K[state] + conc), data = Puromycin,
+ start = list(K = c(0.1, 0.1),
+ Vm = c(200, 200)))

What I cannot figure out is how to specify the value of the grouping 
variable in a 'predict' statement. In my own example, I can only seem to 
get the predictions for the 1st specified level of the grouping 
variable. I promise that I have read the documentation, and have tried a 
number of things, but cannot get the correct predictions.

Thank you for any help.

Yours - Stuart

-- 
/*------------------------------------------------*/
Stuart Rosen, PhD
Professor of Speech and Hearing Science
UCL Speech, Hearing and Phonetic Sciences



More information about the R-help mailing list