[R] plotting additive ns components

John Fox jfox at mcmaster.ca
Thu Jan 28 05:47:19 CET 2010


Dear GlenB,

The allEffects() function in the effects package can make these plots.

I hope this helps,
 John



> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On
> Behalf Of GlenB
> Sent: January-27-10 9:09 PM
> To: r-help at r-project.org
> Subject: [R] plotting additive ns components
> 
> 
> 
> I have an additive model of the following form :
> 
> zmdlfit <- lm(z~ns(x,df=6)+ns(y,df=6))
> 
> I can get the fitted values and plot them against z easily enough, but I
> also want to both obtain and plot the two additive components (the
estimates
> of the two additive terms on the RHS)
> 
> I've been looking at manuals and searching on the internet and searching
the
> archives, but I'm apparently incompetent because I can't locate it - how
do
> I plot just the x and y splines (against x and y)?
> 
> I've read the help on predict.lm, and on predict.ns (/predict.bs) but it
> only shows how to get the new columns for new values of x; I could
multiply
> those by the coefficients of the spline fit, and I could also do it by
> holding each variable fixed while the other varies in predict (which is
> right up to an additive constant), but it seems like there would have to
be
> a more straightforward that way I am missing. It looks like gam and mgcv
do
> it for you, but can I do it with just lm and ns?
> 
> --
> View this message in context: http://n4.nabble.com/plotting-additive-ns-
> components-tp1312375p1312375.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> 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