[R] plot the dependent variable against one of the predictors with other predictors as constant

Greg Snow Greg.Snow at imail.org
Mon Aug 9 20:29:50 CEST 2010


Look at the TkPredict and Predict.Plot functions in the TeachingDemos package as a couple of options.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Yi
> Sent: Saturday, August 07, 2010 3:13 PM
> To: R (r-help at R-project.org)
> Subject: [R] plot the dependent variable against one of the predictors
> with other predictors as constant
> 
> Hi, folks,
> 
> Happy work in weekends >_<
> 
> My question is how to plot the dependent variable against one of the
> predictors with other predictors as constant. Not for the original
> data, but
> after prediction. It means y is the predicted value of the dependent
> variables. The constane value of the other predictors may be the
> average or
> some fixed value.
> 
> #######
> y=1:10
> x=10:1
> z=2:11
> lin_model=lm(z~x+y)
> x_new=11:2
> #######
> 
> 
> How to plot predicted value of z from the regression model with x takes
> x_new and y as a constant (let's say y=1)
> 
> 
> I am thinking about using 'predict' command to generate the prediction
> of z
> with the new data.frame but there should be a better way.
> 
> Thanks all.
> 
> Yi
> 
> 	[[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.



More information about the R-help mailing list