rpanel (version 1.1-4)

rp.surface: Interactive visualisation of a surface and its uncertainty

Description

This function plots a surface and uses interative interrogation by the mouse, or a sequence of animations, to indicate the uncertainty in the surface as an estimate of the true surface.

Usage

rp.surface(surface, covariance, x1grid, x2grid, x, y, Display = "persp",
                       hscale = 1, vscale = hscale, panel = TRUE,
                       Speed = 5, ntime = 10, ninterp = 50,
                       zlim = NULL, col.palette = topo.colors(100), coords = rep(NA, 2))

Arguments

surface

a matrix of estimated surface values over a regular grid.

covariance

the covariance matrix for the estimates in surface, corresponding to the estimates in vector form c(surface).

x1grid, x2grid

vectors defining the regular grids over each margin of surface.

x

an optional two-column matrix of observed covariate values.

y

an optional vector of response values.

Display

a character value which determines the initial type of surface plot. Options are "image" (the default) and "persp".

hscale, vscale

scaling parameters for the size of the plot.

panel

a logical variable which determines whether a panel is created to allow interactive control.

Speed

this determines the initial value of the speed of animations by setting the value of the sleep time (in hundredths of a second, with an offset of 2) between displayed surfaces.

ntime

the number of interpolated surfaces displayed between successive simulated surfaces, to control the smoothness of the animation.

ninterp

the number of grid values in each dimension when constructing a surface for the "image" display option. This is used because the input grid of surface may have quite low resolution which produces a rather chunky image display. A finer grid is constructed if the akima package is avaiable.

zlim

a vector of length two which defines the range of plotting on the surface scale. By default, zlim is determined by the range of surface plus and minus three standard deviations (available from covar).

col.palette

the colour palette used to paint the surface. The colours are determined simply by the height of the surface.

coords

a vector of length two which defines the location where the uncertainty in the surface is examined, thorugh the construction of a variability interval. This applies when panel = FALSE and Display = "image".

Value

Nothing is returned.

Details

The interactive controls allow the surface to be plotted using image or persp displays, and with the display of uncertainty through mouse click and drag on the image plot or animation.

References

rpanel: Simple interactive controls for R functions using the tcltk package. Journal of Statistical Software, 17, issue 9.

Examples

Run this code
# NOT RUN {
if (require(sm)) {
   with(trawl, {
      location  <- cbind(Longitude, Latitude)
      model     <- sm.regression(location, Score1, ngrid = 15, display = "none")
      longitude <- model$eval.points[ , 1]
      latitude  <- model$eval.points[ , 2]
      xgrid     <- as.matrix(expand.grid(longitude, latitude))
      S         <- sm.weight2(location, xgrid, model$h)
      covar     <- tcrossprod(S) * model$sigma^2
      rp.surface(model$estimate, covar, longitude, latitude, location, Score1)
   })
}
# }

Run the code above in your browser using DataCamp Workspace