Description Usage Arguments Format Details Value References See Also Examples
Combine Model-Based Recursive Partitioning with a Constant Classifier.
1 2 3 4 5 6 7 8 9 10 11 |
object |
An object of class "constantModel" and "constant", respectively. |
x |
An object of class "constant". |
weights |
A vector of observation weights. |
out |
Should class labels or posterior probabilities be returned? |
... |
Further arguments. |
Formal class 'StatModel' [package "modeltools"] with 5 slots
This page lists all ingredients to combine a Constant
Classifier with Model-Based Recursive Partitioning
(mob
from package party). See
the example for how to do that.
constantModel
is an object of class
StatModel-class
implemented in
package modeltools that provides an infra-structure
for an unfitted constant
model.
Moreover, methods for constant
and
constantModel
objects for the generic functions
reweight
,
deviance
,
estfun
, and
predict
are provided.
reweight
: The re-weighted fitted "constant Model"
object.
deviance
: The value of the deviance
for the Constant Classifier extracted from object
,
i.e. the log-likelihood.
estfun
: The empirical
estimating (or score) function for the Constant
Classifier, i.e. the derivatives of the log-likelihood
with respect to the parameters, evaluated at the training
data.
predict
: Either a vector of predicted
class labels or a matrix of class posterior
probabilities.
Zeileis, A., Hothorn, T. and Kornik, K. (2008), Model-based recursive partitioning. Journal of Computational and Graphical Statistics, 17(2) 492–514.
reweight
,
deviance
,
estfun
,
predict
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | library(locClassData)
library(party)
data <- vData(500)
x <- seq(0,1,0.05)
grid <- expand.grid(x.1 = x, x.2 = x)
fit <- mob(y ~ x.1 + x.2 | x.1 + x.2, data = data, model = constantModel,
control = mob_control(objfun = deviance, minsplit = 20))
## predict posterior probabilities
pred <- predict(fit, newdata = grid, out = "posterior")
post <- matrix(0, length(pred), 2)
colnames(post) = 1:2
for (i in seq_along(pred))
post[i, colnames(pred[[i]])] = pred[[i]]
image(x, x, matrix(as.numeric(post[,1]), length(x)), xlab = "x.1", ylab = "x.2")
contour(x, x, matrix(as.numeric(post[,1]), length(x)), levels = 0.5, add = TRUE)
points(data$x, pch = as.character(data$y))
## predict node membership
splits <- predict(fit, newdata = grid, type = "node")
contour(x, x, matrix(splits, length(x)), levels = min(splits):max(splits), add = TRUE, lty = 2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.