R/visregPanel.R

Defines functions visregPanel

visregPanel <- function(x, y, subscripts, lframe, lresids, partial, band, rug, top, fill.par, ...) {
  if (band) {
    poly.args <- list(x=c(lframe$xx[subscripts], rev(lframe$xx[subscripts])), y=c(lframe$lwr[subscripts], rev(lframe$upr[subscripts])), subscripts=subscripts, col="gray85", border=F)
    if (length(fill.par)) poly.args[names(fill.par)] <- fill.par
    FUN <- getFromNamespace('panel.polygon', 'lattice')
    do.call(FUN, poly.args)
  }
  current.level <- lframe$by[subscripts][1]
  if (!partial) {
    lattice::panel.xyplot(x, y, subscripts=subscripts,...)
  } else {
    if (top=='line') {
      lattice::panel.points(lresids$x[lresids$by==current.level], lresids$r[lresids$by==current.level])
      lattice::panel.xyplot(x, y, subscripts=subscripts,...)
    } else {
      lattice::panel.xyplot(x, y, subscripts=subscripts,...)
      lattice::panel.points(lresids$x[lresids$by==current.level], lresids$r[lresids$by==current.level])
    }
  }
  
  if (rug==1) lattice::panel.rug(lresids$x[lresids$by==current.level], lwd=1)
  if (rug==2) {
    lattice::panel.rug(lresids$x[lresids$by==current.level & !lresids$pos], lwd=1)
    lattice::panel.rug(lresids$x[lresids$by==current.level & lresids$pos], regular=FALSE, lwd=1)
  }
}

Try the visreg package in your browser

Any scripts or data that you put into this service are public.

visreg documentation built on July 1, 2020, 10:24 p.m.