sm.surface3d: Adding a regression surface to an rgl plot.

sm.surface3dR Documentation

Adding a regression surface to an rgl plot.

Description

This function adds a regression surface, defined by a matrix of heights at a regular grid of values of two covariates, to an rgl plot. Missing values can be accommodated.

Usage

 sm.surface3d(eval.points, surf, scaling, 
                    col = "green", col.mesh = "black", 
                    alpha = 0.7, alpha.mesh = 1, lit = TRUE, ...)

Arguments

eval.points

if this is a two-column matrix then each column defines the marginal grids of covariate values. Alternatively, a list with two components can also be used to handle cases where the grids are of different size.

surf

a matrix of heights corresponding to the grid of covariate values. NAs are allowed.

scaling

a function to define the scaling for the rgl plot. This function is returned by an initial call to rp.plot3d in the rpanel package.

col

the colour of the surface. If col is set to a single value, this is replicated across the two components. However, a matrix of values corresponding to the entries of surf can also be supplied.

col.mesh

the colour of the surface mesh. If col.mesh is set to a single value, this is replicated across the two components. However, a matrix of values corresponding to the entries of surf can also be supplied.

alpha

the transparency of the filled triangles defining the surface. Setting this to 0 will remove the filled triangles from the plot.

alpha.mesh

the transparency of the lines drawn across the regular grid of covariate values. Setting this to 0 will remove the lines from the plot.

lit

a logical variable which controls whether the rgl plot is lit or not.

...

other optional parameters which are passed to material3d in the rgl package.

Details

the principal motivation for this function is that is can handle missing data in regression surfaces. In particular, it can be used to plot the results of applying sm.regression. In addition, the function can be used to build up more complex plots by adding successive surfaces.

Value

a vector of length 2 containing the ids of the filled surface and lines added to the rgl plot.

Side Effects

a surface is added to the rgl plot.

See Also

sm.regression

Examples

with(trawl, {
   Zone93    <- (Year == 1 & Zone == 1)
   Position  <- cbind(Longitude - 143, Latitude)
   model1 <- sm.regression(Position[Zone93,], Score1[Zone93],
        h= c(0.1, 0.1), display = "rgl", xlab="Longitude - 143")
   model2 <- sm.regression(Position[Zone93,], Score1[Zone93],
        h= c(0.2, 0.2), display = "none")
   sm.surface3d(model2$eval.points, model2$est, model1$scaling, col = "red")
})

sm documentation built on May 29, 2024, 2:28 a.m.

Related to sm.surface3d in sm...