Christian Reilly <[EMAIL PROTECTED]> writes: > 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: > > > -------------------- > > f <- yresp ~ xstim^n / (xstim^n + B^n) > > starts <- list(n=.6, B=11) > > myfit <- nls(formula=f, data=df, start = starts) > >myfit > > 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: > > ------------ > > plot(f,data=df) > Error in terms.formula(formula, data = data) : > invalid power in formula > ---------- > > or > > ---------- > > n <- 0.87 > > B <- 5.7 > > plot(f,data=df) > Error in terms.formula(formula, data = data) : > invalid power in formula > ------------
Use predict.nls to get the fitted response curve. See ?predict.nls and especially the example, which you can run with example(predict.nls) ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
