Re: [R] rms package-superposition prediction curve of ols and data points

2012-06-26 Thread Frank Harrell
This is what the addpanel argument to plot.Predict is for, something along
the lines of

ap <- function(...) lpoints(age, weight)
plot(Predict(. . .), addpanel=ap)

Frank


David Winsemius wrote
> 
> On Jun 26, 2012, at 11:29 AM, Sarah Goslee wrote:
> 
>> You could use points() instead of plot() for the second command.
> 
> 
> Ummm. Maybe not. I think think that plot.Predict uses lattice  
> graphics. You may need to use trellis.focus() followed by lpoints().  
> Or use the "+" operation with suitable objects.
> 
> -- 
> David.
> 
> 
>>
>> Sarah
>>
>> On Tue, Jun 26, 2012 at 8:37 AM, achaumont   
>> wrote:
>>> Hello,
>>>
>>> I have a question about the “plot.predict” function in Frank  
>>> Harrell's rms
>>> package.
>>> Do you know how to superpose in the same graph the prediction curve  
>>> of ols
>>> and raw data points?
>>> Put most simply, I would like to combine these two graphs:
>>>
  fit_linear <- ols (y4 ~ rcs(x2,c(5,10,15,20,60,80,90)), x=TRUE,  
 y=TRUE)
 p <- Predict(fit_linear,x2,conf.int=FALSE)
 plot (p, ylim =c(-2,0.5), xlim=c(0,100))  # graph n°1
>>>
 z <- plot  
 (x2,y4,ylim=c(-2,0.5),xlim=c(0,100),type="p",lwd=6,col="blue")
 # graph n°2
>>>
>>> Thanks all,
>>>
>>> Agnès
>>>
>>>
>>>
>>
>>
>> -- 
>> Sarah Goslee
>> http://www.functionaldiversity.org
>>
>> __
>> R-help@ 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.
> 
> David Winsemius, MD
> West Hartford, CT
> 
> __
> R-help@ 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.
> 


-
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: 
http://r.789695.n4.nabble.com/rms-package-superposition-prediction-curve-of-ols-and-data-points-tp4634503p4634566.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] rms package-superposition prediction curve of ols and data points

2012-06-26 Thread David Winsemius


On Jun 26, 2012, at 11:29 AM, Sarah Goslee wrote:


You could use points() instead of plot() for the second command.



Ummm. Maybe not. I think think that plot.Predict uses lattice  
graphics. You may need to use trellis.focus() followed by lpoints().  
Or use the "+" operation with suitable objects.


--
David.




Sarah

On Tue, Jun 26, 2012 at 8:37 AM, achaumont   
wrote:

Hello,

I have a question about the “plot.predict” function in Frank  
Harrell's rms

package.
Do you know how to superpose in the same graph the prediction curve  
of ols

and raw data points?
Put most simply, I would like to combine these two graphs:

 fit_linear <- ols (y4 ~ rcs(x2,c(5,10,15,20,60,80,90)), x=TRUE,  
y=TRUE)

p <- Predict(fit_linear,x2,conf.int=FALSE)
plot (p, ylim =c(-2,0.5), xlim=c(0,100))  # graph n°1


z <- plot  
(x2,y4,ylim=c(-2,0.5),xlim=c(0,100),type="p",lwd=6,col="blue")

# graph n°2


Thanks all,

Agnès






--
Sarah Goslee
http://www.functionaldiversity.org

__
R-help@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.


David Winsemius, MD
West Hartford, CT

__
R-help@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.


Re: [R] rms package-superposition prediction curve of ols and data points

2012-06-26 Thread Sarah Goslee
You could use points() instead of plot() for the second command.

Sarah

On Tue, Jun 26, 2012 at 8:37 AM, achaumont  wrote:
> Hello,
>
> I have a question about the “plot.predict” function in Frank Harrell's rms
> package.
> Do you know how to superpose in the same graph the prediction curve of ols
> and raw data points?
> Put most simply, I would like to combine these two graphs:
>
>>  fit_linear <- ols (y4 ~ rcs(x2,c(5,10,15,20,60,80,90)), x=TRUE, y=TRUE)
>> p <- Predict(fit_linear,x2,conf.int=FALSE)
>> plot (p, ylim =c(-2,0.5), xlim=c(0,100))              # graph n°1
>
>> z <- plot (x2,y4,ylim=c(-2,0.5),xlim=c(0,100),type="p",lwd=6,col="blue")
>> # graph n°2
>
> Thanks all,
>
> Agnès
>
>
>


-- 
Sarah Goslee
http://www.functionaldiversity.org

__
R-help@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.


[R] rms package-superposition prediction curve of ols and data points

2012-06-26 Thread achaumont
Hello, 

I have a question about the “plot.predict” function in Frank Harrell's rms
package.
Do you know how to superpose in the same graph the prediction curve of ols
and raw data points?
Put most simply, I would like to combine these two graphs:

>  fit_linear <- ols (y4 ~ rcs(x2,c(5,10,15,20,60,80,90)), x=TRUE, y=TRUE)
> p <- Predict(fit_linear,x2,conf.int=FALSE)
> plot (p, ylim =c(-2,0.5), xlim=c(0,100))  # graph n°1

> z <- plot (x2,y4,ylim=c(-2,0.5),xlim=c(0,100),type="p",lwd=6,col="blue")  
> # graph n°2

Thanks all, 

Agnès



--
View this message in context: 
http://r.789695.n4.nabble.com/rms-package-superposition-prediction-curve-of-ols-and-data-points-tp4634503.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.