[R] Predicting from an nls model

From: Ranney, Steven <steven.ranney_at_montana.edu>
Date: Thu, 12 Jun 2008 06:42:20 -0600

I keep running up against the same error when I try to plot a line from a nls model. The data is fisheries length/weight data. Code follows:

pow = nls(Weight~alpha*Length^beta, data=wae,

      start=list(alpha=0.0000001, beta=3.0), trace=TRUE)                             
plot(Weight~Length, data = wae, pch=19,
     xlab="Length (mm)", ylab="Weight (g)",
     xlim = c(150,1000), ylim = c(0, 10050))                                            
mod = seq(150, 1000)                                                                    
lines(mod, predict(pow, list(Weight = mod)))

The error I get after I submit the final line is:

Error in xy.coords(x, y) : 'x' and 'y' lengths differ

Like my last post, I'm certain there's something simple I'm overlooking. I've been able to get this to work on other data sets, but _how_ I've been able to get this to work, I'm unsure.

Thanks for your help,


Steven H. Ranney
Graduate Research Assistant (Ph.D)
USGS Montana Cooperative Fishery Research Unit Montana State University
PO Box 173460
Bozeman, MT 59717-3460

phone: (406) 994-6643
fax: (406) 994-7479

        [[alternative HTML version deleted]]

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 12 Jun 2008 - 14:18:34 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 12 Jun 2008 - 15:00:45 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive