Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #566.
This PR was assisted by Claude.
The new function
custom_stat()defines a performance statistic from a user function. Argumentstatsofsummary.vsel(),plot.vsel()andperformances()accepts the result alone or in a list with built-in statistics. Argumentstatofsuggest_size()accepts one such object. The statistic changes only the evaluation and the suggested size; the search does not use it.fun(y, mu, wobs)gets the observed responses, the predictive means and the observation weights of the evaluation set. With cross-validation,muholds the cross-validated predictive means. For the binomial family,yis the proportion of successes andwobsthe number of trials.Argument
typehas two values:"pointwise"(default):funreturns one value per observation, and the statistic is their weighted mean. The standard error and the difference from the baseline model use the same formulas as"acc". The difference pairs the two models by observation, and subsampled LOO CV uses the difference estimator. Net benefit is a mean of pointwise terms, so it uses this type."aggregate":funreturns one value, for example a PR-AUC. The standard error and the intervals come from the bootstrap, as for"auc", with the same bootstrap samples for both models of a difference. This type does not support subsampled LOO CV."acc"and"auc"split a binomial row with several trials into single trials; custom statistics do not. Custom statistics are not available for the augmented-data projection, or for the latent projection withresp_oscale = TRUEand a non-NULLfamily$cats. In these projections,muholds one probability per category.namemust contain only letters, digits and underscores, because the summary table adds suffixes such as.seto it. It must not be a built-in name or a column name of the summary table.higher_bettersets the direction forbaseline = "best"andsuggest_size().The internal
parse_stats()turnsstatsinto the names of the statistics and a list of thecustom_statobjects. Later code uses the names as before, andget_stat()passes custom statistics to the newget_stat_custom(). The code for the built-in statistics does not change, andstats = NAgives the same error as before.test_custom_stats.Rimplements"mse"and"acc"again as pointwise custom statistics and"auc"as an aggregate one. It compares the results with the built-in statistics (tolerance = 1e-10) for thevselobjects ofsetup.R, including K-fold CV, subsampled LOO CV and the latent projection. It also comparessuggest_size()andbaseline = "best". The"mse"comparisons leave out these values of the built-in"mse":deltas, which is log-normal;Other tests cover the argument checks, the
labelin the plot facets, binomial data with more than one trial per row, an all-NAreference model (as in adatafit) and the errors for the unsupported projections.I ran the full test suite with
NOT_CRAN=trueon CSC Roihu (R 4.6.1, testthat 3.3.2, lme4 2.0.6, brms 2.23.0, rstanarm 2.32.2, cmdstanr 0.9.0.9001, CmdStan 2.39.0):Both runs have the same four warnings: three from optimx about scaling in
test_varsel.R, and one lme4 convergence warning intest_datafit.R. The "this PR" row used a commit that differs from this PR only in comments, documentation and the NEWS item. Most new tests need the reference models ofsetup.R, so they run only withNOT_CRAN=true. The tests of the argument checks also run on CRAN.