Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Labeling of cvrisk plots #96

Closed
davidruegamer opened this issue Nov 21, 2018 · 2 comments
Closed

Labeling of cvrisk plots #96

davidruegamer opened this issue Nov 21, 2018 · 2 comments

Comments

@davidruegamer
Copy link
Member

@davidruegamer davidruegamer commented Nov 21, 2018

In the most current version, plot of a cvrisk object has a messed up y label:

data("bodyfat", package = "TH.data")

  ### fit linear model to data
  model <- glmboost(DEXfat ~ ., data = bodyfat, center = TRUE)

  ### AIC-based selection of number of boosting iterations
  maic <- AIC(model)
  maic

  ### inspect coefficient path and AIC-based stopping criterion
  par(mai = par("mai") * c(1, 1, 1, 1.8))
  plot(model)
  abline(v = mstop(maic), col = "lightgray")

  ### 10-fold cross-validation
  cv10f <- cv(model.weights(model), type = "kfold")
  cvm <- cvrisk(model, folds = cv10f, papply = lapply)
  print(cvm)
  mstop(cvm)
  plot(cvm)

This is because in plot.cvrisk the argument ylab = attr(x, "risk") gets only evaluated when ylab is used. By this time, x (the cvrisk object) however is already overwritten and looses the attribute. Here are the correpsonding lines of code:

plot.cvrisk <- function(x, xlab = "Number of boosting iterations",
                        ylab = attr(x, "risk"),
                        ylim = range(x), main = attr(x, "type"), ...) {

    x <- x[, apply(x, 2, function(y) all(!is.na(y))), drop = FALSE] # drops attribute
    cm <- colMeans(x)
    plot(1:ncol(x), cm, ylab = ylab, ylim = ylim,
         type = "n", lwd = 2, xlab = xlab,
         main = main, axes = FALSE, ...)

Will send a pull request in a minute.

davidruegamer added a commit that referenced this issue Nov 21, 2018
@davidruegamer
Copy link
Member Author

@davidruegamer davidruegamer commented Nov 21, 2018

And the same applies for the main label in the plot.

@hofnerb hofnerb closed this in 9611f75 Apr 12, 2019
@hofnerb
Copy link
Member

@hofnerb hofnerb commented Apr 12, 2019

Thanks a lot @davidruegamer for spotting and fixing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.