Skip to content

451: Support for different priors#468

Merged
mercifr1 merged 20 commits into
mainfrom
451-different-priors
Jun 30, 2026
Merged

451: Support for different priors#468
mercifr1 merged 20 commits into
mainfrom
451-different-priors

Conversation

@danielinteractive

@danielinteractive danielinteractive commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

closes #451

For the survival models, we can set different independent normal priors for the coefficients of the covariates in the linear predictor using the prior_normal_vector() specification. Here we can give a vector of the same length as the number of design matrix columns for both the means or standard deviations of the normal distributions, or we can give a single value that will be repeated for all covariates.
For example, say we have 3 design matrix columns, i.e. coefficients, in the linear predictor of the survival model, then we can set the priors for these coefficients as follows:

survival_model <- SurvivalWeibullPH(
    beta = prior_normal_vector(mus = c(-1, 0, 5), sigmas = c(1, 1, 10))
)
survival_model

You can run

head(model.matrix(object@survival))

on a DataJoint object to know the columns of the design matrix and then match the positions. This is kind of a workaround but is already practical to use now. More sophisticated solution might come from #11

To do:

  • Explain current workaround for finding out the design matrix columns

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Unit Tests Summary

    1 files    195 suites   7m 38s ⏱️
  173 tests   158 ✅ 15 💤 0 ❌
1 147 runs  1 130 ✅ 17 💤 0 ❌

Results for commit a74af59.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Unit Test Performance Difference

Test Suite $Status$ Time on main $±Time$ $±Tests$ $±Skipped$ $±Failures$ $±Errors$
LongitudinalRandomEffects 💔 $1.78$ $+62.62$ $0$ $0$ $0$ $0$
compile 💔 $5.39$ $+1.47$ $0$ $0$ $0$ $0$
misc_models 💔 $7.59$ $+1.59$ $0$ $0$ $0$ $0$
model_multi_chain 💔 $7.22$ $+6.58$ $0$ $0$ $0$ $0$
Additional test case details
Test Suite $Status$ Time on main $±Time$ Test Case
DataSurvival 👶 $+0.00$ model.matrix_for_DataSurvival_works_as_expected
Grid 💔 $39.22$ $+10.64$ Grid_objects_work_with_QuantityGenerator_and_QuantityCollapser
GridPrediction 💔 $97.52$ $+27.81$ GridPrediction_works_as_expected_for_Survival_models
JointModelSamples 💔 $28.78$ $+9.29$ print_works_as_expected_for_JointModelSamples
LongitudinalClaretBruno 💔 $5.03$ $+2.17$ LongitudinalClaretBruno_works_as_expected_with_default_arguments
LongitudinalGSF 💔 $5.77$ $+1.68$ LongitudinalGSF_works_as_expected_with_default_arguments
LongitudinalQuantiles 💔 $3.30$ $+3.30$ Test_that_LongitudinalQuantities_works_as_expected
LongitudinalRandomEffects 💔 $1.78$ $+62.62$ LongitudinalRandomEffects_works_as_expected
LongitudinalRandomSlope 💚 $50.72$ $-45.21$ Print_method_for_LongitudinalRandomSlope_works_as_expected
Prior 👶 $+0.00$ prior_normal_vector_works_as_expected
SimJointData 💚 $1.09$ $-1.02$ SimJointData_works_as_expected
SurvivalExponential 👶 $+0.00$ Different_priors_for_the_beta_components_are_possible
SurvivalQuantities 💔 $47.07$ $+16.24$ SurvivalQuantities_and_autoplot.SurvivalQuantities_works_as_expected
compile 💔 $5.39$ $+1.47$ compileStanModel_doesn_t_error_if_the_directory_doesn_t_exist
initialValues 👶 $+0.00$ initialValues_works_also_for_vectorized_parameters
initialValues 👶 $+0.50$ initial_values_for_fixed_distributions_gives_valid_values
initialValues 💀 $0.39$ $-0.39$ intial_values_for_fixed_distributions_gives_valid_values
misc_models 💔 $7.59$ $+1.59$ Longitudinal_Model_doesn_t_print_sampler_rejection_messages
model_multi_chain 💔 $7.22$ $+6.58$ Can_recover_known_distribution_parameters_from_random_slope_model_when_using_multiple_chains
populationHR 💀 $0.01$ $-0.01$ populationHR_works_as_expected_for_alternative_specfications
populationHR 👶 $+0.00$ populationHR_works_as_expected_for_alternative_specifications
populationHR 💔 $15.91$ $+1.63$ populationHR_works_as_expected_for_default_parameters
stan_functions 💔 $11.90$ $+1.01$ GSF_SLD_function_works_as_expected

Results for commit c5d3e12

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

badge

Code Coverage Summary

Filename                           Stmts    Miss  Cover    Missing
-------------------------------  -------  ------  -------  ------------------------------
R/brier_score.R                      173       1  99.42%   272
R/DataJoint.R                         78       0  100.00%
R/DataLongitudinal.R                 126       1  99.21%   251
R/DataSubject.R                       85       1  98.82%   144
R/DataSurvival.R                     103       0  100.00%
R/defaults.R                          13       9  30.77%   17-59, 86
R/generics.R                          36       5  86.11%   53, 391, 412, 475, 493
R/Grid.R                              27       1  96.30%   183
R/GridEven.R                          36       0  100.00%
R/GridEvent.R                         22       0  100.00%
R/GridFixed.R                         30       0  100.00%
R/GridGrouped.R                       54       0  100.00%
R/GridManual.R                        23       3  86.96%   79-81
R/GridObserved.R                      24       0  100.00%
R/GridPopulation.R                    37       4  89.19%   66, 74-76
R/GridPrediction.R                    37       6  83.78%   85, 93-97
R/JointModel.R                       131       9  93.13%   148-153, 203, 207, 252, 325
R/JointModelSamples.R                 81       0  100.00%
R/link_generics.R                     39      16  58.97%   67-70, 93-96, 115-118, 141-144
R/Link.R                              66       4  93.94%   202-205
R/LinkComponent.R                     24       3  87.50%   92, 121-122
R/LongitudinalClaretBruno.R          123       6  95.12%   221-225, 244
R/LongitudinalGSF.R                  138       0  100.00%
R/LongitudinalModel.R                 29       2  93.10%   68, 70
R/LongitudinalQuantities.R            74       0  100.00%
R/LongitudinalRandomEffects.R         65      17  73.85%   86-111
R/LongitudinalRandomSlope.R           62       6  90.32%   139-143, 156
R/LongitudinalSteinFojo.R            117      10  91.45%   204-208, 247-251
R/Parameter.R                         14       0  100.00%
R/ParameterList.R                     42       1  97.62%   188
R/populationHR.R                      63       0  100.00%
R/Prior.R                            345       8  97.68%   313, 345, 693, 847-861
R/Promise.R                           29       0  100.00%
R/Quantities.R                        61       0  100.00%
R/QuantityGeneratorPopulation.R       23       0  100.00%
R/QuantityGeneratorPrediction.R       48       0  100.00%
R/QuantityGeneratorSubject.R          21       0  100.00%
R/settings.R                          14      14  0.00%    62-78
R/SimGroup.R                           5       0  100.00%
R/SimJointData.R                     180      10  94.44%   133, 302-310
R/SimLongitudinal.R                    5       2  60.00%   22, 41
R/SimLongitudinalClaretBruno.R       107       0  100.00%
R/SimLongitudinalGSF.R               107       0  100.00%
R/SimLongitudinalRandomSlope.R        55       0  100.00%
R/SimLongitudinalSteinFojo.R          77       0  100.00%
R/SimSurvival.R                      165       0  100.00%
R/simulate.R                         364     364  0.00%    47-551
R/StanModel.R                         16       0  100.00%
R/StanModule.R                       186       6  96.77%   202-203, 247, 258, 409, 437
R/SurvivalExponential.R               14       0  100.00%
R/SurvivalGamma.R                     17       0  100.00%
R/SurvivalLoglogistic.R               15       0  100.00%
R/SurvivalModel.R                     20       0  100.00%
R/SurvivalQuantities.R               172       1  99.42%   127
R/SurvivalWeibullPH.R                 25       0  100.00%
R/utilities.R                        149       2  98.66%   15, 351
R/zzz.R                               31      28  9.68%    3-7, 9-32, 39-48
TOTAL                               4223     540  87.21%

Diff against main

Filename                          Stmts    Miss  Cover
------------------------------  -------  ------  --------
R/DataSurvival.R                     +2       0  +100.00%
R/LongitudinalClaretBruno.R          +1       0  +0.04%
R/LongitudinalGSF.R                  +1       0  +100.00%
R/LongitudinalModel.R                +9      +2  -6.90%
R/LongitudinalRandomSlope.R          +2       0  +0.32%
R/LongitudinalSteinFojo.R            +1       0  +0.07%
R/Prior.R                           +66      +2  -0.17%
R/settings.R                         +2      +2  +100.00%
R/SimLongitudinalRandomSlope.R       +5       0  +100.00%
TOTAL                               +89      +6  +0.13%

Results for commit: 7b0d59d

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@mercifr1 mercifr1 merged commit 27f9e31 into main Jun 30, 2026
24 checks passed
@mercifr1 mercifr1 deleted the 451-different-priors branch June 30, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow different priors for different covariates

2 participants