From 123e769c2e6e944f72cf1d0345420124fd5e8539 Mon Sep 17 00:00:00 2001 From: eogoodwin <34554459+eogoodwin@users.noreply.github.com> Date: Thu, 11 Jan 2018 15:26:29 +1300 Subject: [PATCH 1/2] Update termplot.R The help page for termplot states that it adds (optionally) standard errors around the partial plots for each predictor. However, until now it has multiplied the standard error (returned by predict() function) by 2.0, to generate an approximate 95% confidence interval, rather than a standard error. --- src/library/stats/R/termplot.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/stats/R/termplot.R b/src/library/stats/R/termplot.R index 67be5c3ee..e7447b819 100644 --- a/src/library/stats/R/termplot.R +++ b/src/library/stats/R/termplot.R @@ -133,7 +133,7 @@ termplot <- function(model, data = NULL, envir = environment(formula(model)), if (!is.null(which.terms)) pres <- pres[, which.terms, drop = FALSE] } - se.lines <- function(x, iy, i, ff = 2) { + se.lines <- function(x, iy, i, ff = 1) { tt <- ff * terms$se.fit[iy, i] lines(x, tms[iy, i] + tt, lty = lty.se, lwd = lwd.se, col = col.se) lines(x, tms[iy, i] - tt, lty = lty.se, lwd = lwd.se, col = col.se) From 6ec2da31acb1685a24927e18304d92274045d70d Mon Sep 17 00:00:00 2001 From: eogoodwin <34554459+eogoodwin@users.noreply.github.com> Date: Fri, 12 Jan 2018 09:24:57 +1300 Subject: [PATCH 2/2] Expose SE scaler as a termplot argument Allow the user to specify the multiple of SE to plot, allowing selection of either SE intervals, or confidence intervals. --- src/library/stats/R/termplot.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/library/stats/R/termplot.R b/src/library/stats/R/termplot.R index e7447b819..1ed7fef52 100644 --- a/src/library/stats/R/termplot.R +++ b/src/library/stats/R/termplot.R @@ -18,7 +18,7 @@ termplot <- function(model, data = NULL, envir = environment(formula(model)), partial.resid = FALSE, - rug = FALSE, terms = NULL, se = FALSE, + rug = FALSE, terms = NULL, se = FALSE, ff=1, xlabs = NULL, ylabs = NULL, main = NULL, col.term = 2, lwd.term = 1.5, col.se = "orange", lty.se = 2, lwd.se = 1, @@ -133,7 +133,7 @@ termplot <- function(model, data = NULL, envir = environment(formula(model)), if (!is.null(which.terms)) pres <- pres[, which.terms, drop = FALSE] } - se.lines <- function(x, iy, i, ff = 1) { + se.lines <- function(x, iy, i, ff = ff) { tt <- ff * terms$se.fit[iy, i] lines(x, tms[iy, i] + tt, lty = lty.se, lwd = lwd.se, col = col.se) lines(x, tms[iy, i] - tt, lty = lty.se, lwd = lwd.se, col = col.se)