[R] plotting predicted values (lines) over data?

2004-01-15 Thread Jeff D. Hamann
I've been trying to plot the predicted values, as a line, over the data for
a simple nonlinear fit with the following commands:

plot( hg ~ ht )
... define some function hg ~ ht + junk ...
... blah, blah, obtain parameter estimates and predicted values, blah...
... then...
lines( sort( $predicted ) ~ sort( ht ) )

which results in a line that isn't smooth (which I knew would happen). I've
checked the FAQ,docs and archives and I'm not sure if there's function that
will so what Heut et. al (2004) do with their plfit(). So, is there already
an R function, or process to do this, or will I have to write one?

Thanks,
Jeff.

---
Jeff D. Hamann
Forest Informatics, Inc.
PO Box 1421
Corvallis, Oregon USA 97339-1421
(office) 541-754-1428
(cell) 541-740-5988
[EMAIL PROTECTED]
www.forestinformatics.com

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] plotting predicted values (lines) over data?

2004-01-15 Thread Liaw, Andy
 From: Jeff D. Hamann
 
 I've been trying to plot the predicted values, as a line, 
 over the data for
 a simple nonlinear fit with the following commands:
 
 plot( hg ~ ht )
 ... define some function hg ~ ht + junk ...
 ... blah, blah, obtain parameter estimates and predicted 
 values, blah...
 ... then...
 lines( sort( $predicted ) ~ sort( ht ) )

This doesn't look right to me.  Don't you want something like:

  ord - order(ht)
  lines(ht[ord], fit$predicted[ord], ...)

???

Andy

 
 which results in a line that isn't smooth (which I knew would 
 happen). I've
 checked the FAQ,docs and archives and I'm not sure if there's 
 function that
 will so what Heut et. al (2004) do with their plfit(). So, is 
 there already
 an R function, or process to do this, or will I have to write one?
 
 Thanks,
 Jeff.
 
 ---
 Jeff D. Hamann
 Forest Informatics, Inc.
 PO Box 1421
 Corvallis, Oregon USA 97339-1421
 (office) 541-754-1428
 (cell) 541-740-5988
 [EMAIL PROTECTED]
 www.forestinformatics.com
 


--
Notice:  This e-mail message, together with any attachments,...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] plotting predicted values (lines) over data?

2004-01-15 Thread John Fox
Dear Jeff,

I'm not sure that I follow entirely what you've done, but perhaps the 
following suggestions will help: (1) If the plotted curve isn't smooth 
because it's evaluated at too few x-values or at x-values that are too 
unevenly spaced, what about getting a sufficient number of predicted values 
[via predict()] that are evenly spaced along the range of ht -- i.e., not 
at the observations? (2) Rather than connecting the fitted values with line 
segments, you could use spline() to interpolate.

I hope that this helps,
 John
At 11:23 AM 1/15/2004 -0800, Jeff D. Hamann wrote:
I've been trying to plot the predicted values, as a line, over the data for
a simple nonlinear fit with the following commands:
plot( hg ~ ht )
... define some function hg ~ ht + junk ...
... blah, blah, obtain parameter estimates and predicted values, blah...
... then...
lines( sort( $predicted ) ~ sort( ht ) )
which results in a line that isn't smooth (which I knew would happen). I've
checked the FAQ,docs and archives and I'm not sure if there's function that
will so what Heut et. al (2004) do with their plfit(). So, is there already
an R function, or process to do this, or will I have to write one?
Thanks,
Jeff.
-
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: [EMAIL PROTECTED]
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html