[R] Plotting a Regression holding some exogeneous constant.

Greg Snow 538280 at gmail.com
Wed May 7 19:20:45 CEST 2014


The Predict.Plot function in the TeachingDemos package can do this for
you.  Or you can just calculate the intercept for the call to abline
by plugging in the mean for all the other variables and do the
arithmetic then pass the intercept and slope by hand to the abline
function.  Or you can create a new data frame with a range of values
for the one variable (to be your x-axis) and the means for all the
others, then use the predict function to get the predictions for these
values and add them to the plot using the lines function (instead of
abline).

On Mon, May 5, 2014 at 5:57 AM, Katharina Mersmann
<kmersman at smail.uni-koeln.de> wrote:
> Dear R-community,
>
> I am totally lost and need help.
>
> For a Visualization  I need to plot two regressions in the same plot.  The
> intention is to provide a visual basis for a synthesized theoretical
> discussion.
>
>
>
> 1.)    fixed.1<-plm(CSmean~ FCRlong, data = data.plm, index =
> c("countrynr","quartal"),model = "within")
>
> 2.)    fixed.2<-plm(FCRlong ~ GDP+ GDPpCapita+ budget+ percentDebt+
> primSurplus
>
>               +Inflation+lagBY,
>
>                data = data.plm, index = c("countrynr","quartal"),model =
> "within"
>
> Usually I would do
>
>>plot(data.plm$ FCRlong,data.plm$BY,ylim = c(0,20))
>
>>abline(fixed.1)
>
>>abline(fixed.2)
>
>
>
> For Regression Number one, “fixed.1”, it´s easy, because I have only two
> Dimensions, but here I need to do a parallel shift by adding an average
> Value, say 4, (to solve for  CSmean to BY)
>
> So loosely speaking, I want to plot  fixed.1+4 ? What shall I do in this
> case?
>
>
>
> Second, in Regression “fixed.2” I have a Hyperplane, but for a synthesized
> general discussion the exogeneous variables, except lagBY, shall be set to
> their average values
>
> in the panel-dataset. With this restriction I am able to plot Regression 2
> in the two-dimensional-plot as well.
>
> But I am not even sure how to reconstruct this by a code?
>
>
>
>
>
> I unfortunately can´t give you an reproduceable example,
>
> But any suggestions or hints or just a link to a similar problem would be
> helpful
>
>
>
> Thank you!
>
> Katie
>
>
>         [[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.
>



-- 
Gregory (Greg) L. Snow Ph.D.
538280 at gmail.com



More information about the R-help mailing list