plot3d.localpoly.reg {NonpModelCheck} | R Documentation |
Create a 3d plot from a local polynomial fit of two covariates and a response variable.
plot3d.localpoly.reg(X,Y, bandwidth = "CV", gridsize = 30, degree.pol = 0, kernel.type = "epanech", gridsurface = 30, xlab=expression(X_1), ylab=expression(X_2), zlab=expression(Y), theta = 30, phi = 30, expand = 0.5, col = "lightblue", ltheta = 120, shade = 0.75, ticktype = "detailed", pch = 16,...)
X |
n by 2 matrix with observations, rows corresponding to data points and columns correspond to covariates. |
Y |
vector of observed responses. |
bandwidth |
bandwidth, vector or matrix. If "CV", leave-one-out cross validation with criterion of minimum MSE is performed to select a unique bandwidth that will be used for all dimensions of X; if "GCV", Generalized Cross Validation is performed to select a unique bandwidth that will be used for all dimensions of X; if "CV2" leave-one-out cross validation for each covariate; and if "GCV2", GCV for each covariate. It may be a vector for each dimension of the X; or a matrix of bandwidths (not to be confused with bandwidth matrix H), where each row is a vector of size 2, representing a bandwidth that changes with the location of estimation for the grid. See localpoly.reg. |
gridsize |
number of possible bandwidths to be searched in cross-validation. If left as default 0, gridsize is taken to be 5+as.integer(100/d^3). If cross-validation is not performed, it is ignored. |
degree.pol |
degree of the polynomial to be used in the local fit. |
kernel.type |
kernel type, options are "box", "trun.normal", "gaussian", "epanech", |
gridsurface |
number of points on each axis at which to estimate the local polynomial surface. |
xlab |
parameter for persp |
ylab |
parameter for persp |
zlab |
parameter for persp |
theta |
parameter for persp |
phi |
parameter for persp |
expand |
parameter for persp |
col |
parameter for persp |
ltheta |
parameter for persp |
shade |
parameter for persp |
ticktype |
parameter for persp |
pch |
parameter for persp |
... |
further parameters for plotting persp |
Uses function "persp" to plot the estimated surface of a local polynomial fit in a nonparametric model with two covariates. The surface is estimated at points of a grid with size "gridsurface", which are evenly distributed between the minimum and maximum of the observed predictors. It also adds the observed points to the plot.
X |
the same input matrix |
Y |
the same input response vector |
points |
points at which to get smoothed values |
bandwidth |
bandwidth used for the polynomial fit |
predicted |
matrix with the predicted values at grid points |
Adriano Zanin Zambom <adriano.zambom@gmail.com>
X = matrix(0,50,2) X[,1] = runif(50,-2,2) X[,2] = runif(50,-2,2) Y = 4*sin(pi*X[,1]) + X[,2] + rnorm(50) plot3d.localpoly.reg(X,Y, bandwidth="CV2", gridsize = 15, degree.pol = 0, gridsurface=20)