Description Usage Arguments Details Value References See Also Examples
A local version of multinomial regression from package nnet that puts increased emphasis on a good model fit near the decision boundary.
1 2 |
formula |
A formula expression as for regression models, of the form
|
data |
An optional data frame in which to interpret the variables occurring
in |
weights |
Initial case weights in fitting (defaults to a vector of 1s). |
subset |
Expression saying which subset of the rows of the data should be used in the fit. All observations are included by default. |
na.action |
A function to filter missing data. |
contrasts |
A list of contrasts to be used for some or all of the factors appearing as variables in the model formula. |
Hess |
Logical for whether the Hessian (the observed/expected information matrix) should be returned. |
censored |
Logical. If the response is a matrix with K > 2 classes, interpret the entries as one for possible classes, zero
for impossible classes. Defaults to |
model |
Logical. If |
... |
Additional arguments for
|
The idea of Hand and Vinciotti (2003) to put increased weight on observations near the decision boundary is generalized to the multiclass case and applied to
multinomial regression.
Since the decision boundary is not known in advance an iterative procedure is required.
First, an unweighted multinomial regression model is fitted to the data.
Based on the differences between the two largest estimated posterior probabilities observation weights are calculated.
Then a weighted multinomial regression model (see multinom
) is fitted using these weights.
Calculation of weights and model fitting is done several times in turn.
The number of iterations is determined by the itr
-argument that defaults to 3.
The name of the window function (wf
) can be specified as a character string.
In this case the window function is generated internally in damultinom
. Currently
supported are "biweight"
, "cauchy"
, "cosine"
, "epanechnikov"
,
"exponential"
, "gaussian"
, "optcosine"
, "rectangular"
and
"triangular"
.
Moreover, it is possible to generate the window functions mentioned above in advance
(see wfs
) and pass them to damultinom
.
Any other function implementing a window function can also be used as wf
argument.
This allows the user to try own window functions.
See help on wfs
for details.
damultinom
calls dannet
. The variables on the rhs of
the formula should be roughly scaled to [0,1] or the fit will be slow
or may not converge at all.
Observation weights that reflect the importance of training observations for the fit
at a particular test observation are calculated internally in damultinom
.
For this reason not all types of response in formula
are allowed and damultinom
does not take all arguments
that can be passed to multinom
.
As response in formula
factors and matrices are allowed. If censored = FALSE
only zero-one class indicator matrices are
allowed.
Argument summ
that specifies a method to summarize rows of the model matrix is missing since this requires adjustment of the case weights.
A "damultinom"
object (that inherits from "dannet"
and "nnet"
) with additional components:
deviance |
The residual deviance, compared to the full saturated model (that explains individual observations exactly). Also, minus twice log-likelihood. |
edf |
The (effective) number of degrees of freedom used by the model. |
AIC |
The AIC for this fit. |
Hessian |
(if |
model |
(if |
Hand, D. J., Vinciotti, V. (2003), Local versus global models for classification problems: Fitting models where it matters, The American Statistician, 57(2) 124–130.
Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth edition. Springer.
multinom
, dannet
, nnet
, predict.damultinom
.
1 2 3 4 5 6 7 | fit <- damultinom(Species ~ Sepal.Length + Sepal.Width, data = iris, wf = "gaussian", bw = 0.5, Hess=TRUE)
pred <- predict(fit)
mean(pred$class != iris$Species)
fit <- damultinom(Species ~ Sepal.Length + Sepal.Width, data = iris, wf = "gaussian", bw = 0.5, weights=1:nrow(iris), trace=FALSE)
pred <- predict(fit)
mean(pred$class != iris$Species)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.