
Last chance! 50% off unlimited learning
Sale ends in
A (filled) contour or perspective plot of a fitted model.
plotModel(
object,
which = if (ncol(object$x) > 1 & tolower(type) != "singledim") { 1:2 } else {
1 },
constant = object$x[which.min(object$y), ],
xlab = paste("x", which, sep = ""),
ylab = "y",
type = "filled.contour",
...
)
fit created by a modeling function, e.g., buildRandomForest
.
a vector with two elements, each an integer giving the two independent variables of the plot (the integers are indices of the respective data set).
a numeric vector that states for each variable a constant value that it will take on
if it is not varied in the plot. This affects the parameters not selected by the which
parameter.
By default, this will be fixed to the best known solution, i.e., the one with minimal y-value, according
to which.min(object$y)
. The length of this numeric vector should be the same as the number of columns in object$x
a vector of characters, giving the labels for each of the two independent variables.
character, the value of the dependent variable predicted by the corresponding model.
string describing the type of the plot: "filled.contour"
(default), "contour"
,
"persp"
(perspective), or "persp3d"
plot.
Note that "persp3d" is based on the plotly package and will work in RStudio, but not in the standard RGui.
additional parameters passed to the contour
or filled.contour
function.
# NOT RUN {
## generate random test data
testfun <- function (x) sum(x^2)
set.seed(1)
k <- 30
x <- cbind(runif(k)*15-5,runif(k)*15,runif(k)*2-7,runif(k)*5+22)
y <- as.matrix(apply(x,1,testfun))
fit <- buildLM(x,y)
plotModel(fit)
plotModel(fit,type="contour")
plotModel(fit,type="persp")
plotModel(fit,which=c(1,4))
plotModel(fit,which=2:3)
# }
Run the code above in your browser using DataLab