Skip to content
Prev 41039 / 398498 Next

problem plotting curve through data

I'm having trouble plotting a curve (basically a dose-response
function) through a set of data.

I have created a dataframe (df) of Stimulus Intensities (xstim) and
Normalized Responses (yresp), and I've used nls() to calculate a nonlinear
regression, like so:


--------------------
Nonlinear regression model
  model:  yresp ~ xstim^n/(xstim^n + B^n)
   data:  df
        n         B
0.8476233 5.7943791
 residual sum-of-squares:  0.03913122
-----------

Which seems great, but I'd like to be able to plot this curve through my
data to see how the fit looks.

when I try:

------------
Error in terms.formula(formula, data = data) :
	invalid power in formula
----------

or

----------
Error in terms.formula(formula, data = data) :
	invalid power in formula
------------

If anyone can give me any tips on this "Error in terms.formula" message,
or how functions are plotted over data, I'd be much obliged. I've only
been at about a R, some no explanations or suggestions are too simplistic.
Even an example of a plot of a logistic growth function of the form

R = S^n / ( S^n + S50^n)

where R is response, S is stimulus intensity and S50 is the intensity that
produces a 50% response

would be tremendously helpful



Cheers,

and many thanks,

Christian

-----------------------------------------------------------------------
Christian Reilly			http://www.stanford.edu/~heron
Hopkins Marine Station
Pacific Grove, CA 93950
heron at stanford.edu