[R] Adjusting the x axis range in effects plots
John Fox
jfox at mcmaster.ca
Wed Feb 5 02:31:56 CET 2014
Dear Mark,
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Mark Hovenden
> Sent: Tuesday, February 04, 2014 6:52 PM
> To: r-help at r-project.org
> Subject: [R] Adjusting the x axis range in effects plots
>
> G'day All,
> I am having some difficulties with effects plots from the effects
> package. I am doing partial regression analyses of normal linear models
> and obtain lovely effect plots with a linear effect line and 95%CL. No
> problem so far.
> The problem is that I want to overlay the actual datapoints on the plot
> and, when I do so, I find that several of them are falling off the edge
> of the plot. In other words the x-axis range is too narrow to show all
> the data points. When I try to adjust the plot using xlim, then nothing
> happens. I can adjust the plots with ylim, color etc but the range of
> the x axis seems to be set somewhere in the package, and xlim disabled,
> and as far as I can see that is a problem because the axis range
> doesn't always fit the actual data range.
>
See the xlevels argument to Effect() in ?Effect; you can set any values you
want for which the effect is evaluated.
> It doesn't seem anyone else has posted about this problem.
>
> Am I wasting my time trying to adjust the x range in plots from the
> "effects" package? If so, is there a way to output the partial
> regression + confidence limit lines so that I can just plot them up
> myself not using effects?
>
Yes, the object returned by Effect() includes components fit, upper, and
lower. See the description in ?Effect.
Additional comment: If there is more than one predictor in the model, it's
not obvious what points to plot, particularly if there is an interaction
between continuous predictors. The development version of the effects
package on R-Forge includes the ability to compute and plot partial
residuals for effects. Their definition isn't entirely straightforward, and
the implementation is preliminary, but if you want to try it, you can
install the package from R-Forge and see the partial.residuals argument in
?Effect.
I hope this helps,
John
> Thanks for any pointers.
> Mark
>
> A/Prof. Mark Hovenden Locked Bag 55
> School of Biological Sciences Hobart Tas. 7001
> University of Tasmania Australia
> phone: +61 3 6226 7874
> fax: +61 3 6226 2698
>
> ______________________________________________
> 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