sm.regression {sm} | R Documentation |
This function creates a nonparametric regression estimate from data consisting of a single response variable and one or two covariates. With one covariate, an interactive panel can be activated to control the smoothing parameter. In two dimensions a perspective plot of the estimated regression surface is produced. A number of other features of the construction of the estimate, and of its display, can be controlled.
sm.regression(x, y, h, design.mat = NA, model = "none", test = TRUE, weights = rep(1, nobs), ...)
x |
a vector, or two-column matrix, of covariate values. |
y |
a vector of reponses. |
h |
a vector of length 1 or 2 giving the smoothing parameter. A normal kernel
function is used and h is its standard deviation.
|
design.mat |
the design matrix used to produce y when these are assumed to be the
residuals from a linear model.
|
model |
a character variable which defines a reference model. The values
"none" , "no effect" and "linear" are possible.
|
test |
a logical flag controlling the production of a formal test, using the reference model as the null hypothesis. |
weights |
a vector which allows the kernel functions associated with the observations
to take different weights. This is useful, in particular, when different
observations have different precisions. This argument applies only to the
case of one covariate.
Use of this parameter is incompatible with binning; hence nbins must
then be set to 0 or left at its default value NA .
|
... |
other optional parameters are passed to the sm.options function, through
a mechanism which limits their effect only to this call of the function;
those relevant for this function are the following:
|
see Chapters 3, 4 and 5 of the reference below.
a list containing the values of the estimate at the evaluation points,
the smoothing parameter and the smoothing parameter weights. If a reference
model has been specified and test
set to T
, then the p-value of the test
is also returned. When there is only one covariate, the weights associated
with different obserations, an estimate of the error standard deviation and
the standard error of the estimate are also returned. If a reference model
has been specified, this standard error refers to the comparison between
the estimate and the reference model, and the values defining the reference
model are also returned.
a plot on the current graphical device is produced, unless display="none"
.
Bowman, A.W. and Azzalini, A. (1997). Applied Smoothing Techniques for Data Analysis: the Kernel Approach with S-Plus Illustrations. Oxford University Press, Oxford.
hcv
, sm
, sm.ancova
, sm.binomial
, sm.poisson
, sm.regression.autocor
,
sm.survival
, sm.options
# An example with one covariate x <- runif(100,-2, 2) y <- x^2 + rnorm(50) sm.regression(x, y, h=0.5) # An example with one covariate x <- cbind(runif(100,-2, 2), runif(100,-2, 2)) y <- x[,1]^2 + x[,2]^2 + rnorm(50) sm.regression(x, y, h=c(1,1))