termplot                package:stats                R Documentation

_P_l_o_t _r_e_g_r_e_s_s_i_o_n _t_e_r_m_s

_D_e_s_c_r_i_p_t_i_o_n:

     Plots regression terms against their predictors, optionally with
     standard errors and partial residuals added.

_U_s_a_g_e:

     termplot(model, data = NULL, envir = environment(formula(model)),
              partial.resid = FALSE, rug = FALSE,
              terms = NULL, se = FALSE,
              xlabs = NULL, ylabs = NULL, main = NULL,
              col.term = 2, lwd.term = 1.5,
              col.se = "orange", lty.se = 2, lwd.se = 1,
              col.res = "gray", cex = 1, pch = par("pch"),
              col.smth = "darkred", lty.smth = 2, span.smth = 2/3,
              ask = dev.interactive() && nb.fig < n.tms,
              use.factor.levels = TRUE, smooth = NULL, ylim = "common",
              ...)

_A_r_g_u_m_e_n_t_s:

   model: fitted model object

    data: data frame in which variables in 'model' can be found

   envir: environment in which variables in 'model' can be found

partial.resid: logical; should partial residuals be plotted?

     rug: add rugplots (jittered 1-d histograms) to the axes?

   terms: which terms to plot (default 'NULL' means all terms)

      se: plot pointwise standard errors?

   xlabs: vector of labels for the x axes

   ylabs: vector of labels for the y axes

    main: logical, or vector of main titles;  if 'TRUE', the model's
          call is taken as main title, 'NULL' or 'FALSE' mean no
          titles.

col.term, lwd.term: color and line width for the 'term curve', see
          'lines'.

col.se, lty.se, lwd.se: color, line type and line width for the
          'twice-standard-error curve' when 'se = TRUE'.

col.res, cex, pch: color, plotting character expansion and type for
          partial residuals, when 'partial.resid = TRUE', see 'points'.

     ask: logical; if 'TRUE', the user is _ask_ed before each plot, see
          'par(ask=.)'.

use.factor.levels: Should x-axis ticks use factor levels or numbers for
          factor terms?

  smooth: 'NULL' or a function with the same arguments as
          'panel.smooth' to draw a smooth through the partial residuals
          for non-factor terms

lty.smth, col.smth, span.smth: Passed to 'smooth'

    ylim: an optional range for the y axis, or '"common"' when a range
          sufficient for all the plot will be computed, or '"free"'
          when limits are computed for each plot.

     ...: other graphical parameters.

_D_e_t_a_i_l_s:

     The model object must have a 'predict' method that accepts
     'type=terms', eg 'glm' in the 'base' package, 'coxph' and
     'survreg' in the 'survival' package.

     For the 'partial.resid=TRUE' option it must have a 'residuals'
     method that accepts 'type="partial"', which 'lm' and 'glm' do.

     The 'data' argument should rarely be needed, but in some cases
     'termplot' may be unable to reconstruct the original data frame.
     Using 'na.action=na.exclude' makes these problems less likely.

     Nothing sensible happens for interaction terms.

_S_e_e _A_l_s_o:

     For (generalized) linear models, 'plot.lm' and 'predict.glm'.

_E_x_a_m_p_l_e_s:

     require(graphics)

     had.splines <- "package:splines" %in% search()
     if(!had.splines) rs <- require(splines)
     x <- 1:100
     z <- factor(rep(LETTERS[1:4],25))
     y <- rnorm(100, sin(x/10)+as.numeric(z))
     model <- glm(y ~ ns(x,6) + z)

     par(mfrow=c(2,2)) ## 2 x 2 plots for same model :
     termplot(model, main = paste("termplot( ", deparse(model$call)," ...)"))
     termplot(model, rug=TRUE)
     termplot(model, partial.resid=TRUE, se = TRUE, main = TRUE)
     termplot(model, partial.resid=TRUE, smooth=panel.smooth, span.smth=1/4)
     if(!had.splines && rs) detach("package:splines")

