-
-
Notifications
You must be signed in to change notification settings - Fork 28
Support censoring (in latent projection) #528
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
base: master
Are you sure you want to change the base?
Changes from all commits
c614b59
6b76269
47139d5
a8ce636
a3040fe
c6a276a
7ad6373
1bdd768
f8f015b
3face64
6971643
23f4619
d18fdbe
01bcdb7
3321973
b820d1d
2349c94
6ae1062
defb5ea
7a1848e
53ef198
d20fa97
64a6482
1451259
fe0ee4a
b67f205
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,3 +14,4 @@ | |
| ^CRAN-SUBMISSION$ | ||
| ^docs$ | ||
| ^_pkgdown\.yml$ | ||
| ^pkgdown$ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -156,8 +156,8 @@ | |
| #' The function supplied to argument `latent_ll_oscale` needs to have the | ||
| #' prototype | ||
| #' ```{r, eval = FALSE} | ||
| #' latent_ll_oscale(ilpreds, dis, y_oscale, wobs = rep(1, length(y_oscale)), | ||
| #' cl_ref, wdraws_ref = rep(1, length(cl_ref))) | ||
| #' latent_ll_oscale(ilpreds, dis, y_oscale, wobs = rep(1, ncol(ilpreds)), | ||
| #' cens, cl_ref, wdraws_ref = rep(1, length(cl_ref))) | ||
| #' ``` | ||
| #' where: | ||
| #' * `ilpreds` accepts the return value from `latent_ilink`. | ||
|
|
@@ -167,18 +167,38 @@ | |
| #' the original response scale. | ||
| #' * `wobs` accepts a numeric vector of length \eqn{N} containing observation | ||
| #' weights. | ||
| #' * `cens` accepts a vector containing censoring indicators for the | ||
| #' observations for which to calculate the response-scale log-likelihood values | ||
| #' (i.e., for the observations from the second dimension of `ilpreds`). This is | ||
| #' only relevant if attribute `cens_var` of `latent_ll_oscale` is not `NULL` | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does not need to have a default value because all calls to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you clarify the documentation?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean to add something like "Argument |
||
| #' (see below). | ||
| #' * `cl_ref` accepts the same input as argument `cl_ref` of `latent_ilink`. | ||
| #' * `wdraws_ref` accepts the same input as argument `wdraws_ref` of | ||
| #' `latent_ilink`. | ||
| #' | ||
| #' In case of censoring (in the response values, i.e., survival or time-to-event | ||
| #' analysis), the latent projection (with response-scale analyses) can be used | ||
| #' by setting an attribute `cens_var` of the `latent_ll_oscale` function to a | ||
| #' right-hand side formula with the name of the variable containing the | ||
| #' censoring indicators (e.g., `0` = uncensored, `1` = censored) on its | ||
| #' right-hand side. This variable named in the `cens_var` attribute is then | ||
| #' retrieved (internally, whenever calling the `latent_ll_oscale` function) from | ||
| #' the original dataset (possibly subsetted to the observations corresponding to | ||
| #' the second dimension of `ilpreds`), `newdata`, or element `data` from | ||
| #' [varsel()]'s argument `d_test`, whichever is applicable. The content of the | ||
| #' retrieved variable is passed to argument `cens` of the `latent_ll_oscale` | ||
| #' function. Note that only the performance statistics `"elpd"`, `"mlpd"`, and | ||
| #' `"gmpd"` take censoring into account (on response scale). | ||
| #' | ||
| #' The return value of `latent_ll_oscale` needs to be an \eqn{S \times N}{S x N} | ||
| #' matrix containing the response-scale (not latent-scale) log-likelihood values | ||
| #' for the \eqn{N} observations from its inputs. | ||
| #' | ||
| #' The function supplied to argument `latent_ppd_oscale` needs to have the | ||
| #' prototype | ||
| #' ```{r, eval = FALSE} | ||
| #' latent_ppd_oscale(ilpreds_resamp, dis_resamp, wobs, cl_ref, | ||
| #' latent_ppd_oscale(ilpreds_resamp, dis_resamp, | ||
| #' wobs = rep(1, ncol(ilpreds_resamp)), cl_ref, | ||
| #' wdraws_ref = rep(1, length(cl_ref)), idxs_prjdraws) | ||
| #' ``` | ||
| #' where: | ||
|
|
@@ -322,6 +342,16 @@ extend_family <- function(family, | |
| "work on response scale (only on latent scale).") | ||
| } | ||
| } | ||
| # Check for argument `dis` because it was added in v2.9.0 and hence after | ||
| # the introduction of the latent projection from v2.4.0: | ||
| if (!any(c("dis", "...") %in% methods::formalArgs(latent_ll_oscale))) { | ||
| stop("Please add argument `dis` to the `latent_ll_oscale` function.") | ||
| } | ||
| # Check for argument `cens` because it was added after v2.9.1 and hence | ||
| # after the introduction of the latent projection from v2.4.0: | ||
| if (!any(c("cens", "...") %in% methods::formalArgs(latent_ll_oscale))) { | ||
| stop("Please add argument `cens` to the `latent_ll_oscale` function.") | ||
| } | ||
| if (is.null(latent_ppd_oscale)) { | ||
| if (!is.null(family$cats)) { | ||
| latent_ppd_oscale <- latent_ppd_oscale_cats | ||
|
|
@@ -337,6 +367,13 @@ extend_family <- function(family, | |
| "response scale (only on latent scale).") | ||
| } | ||
| } | ||
| # Check for argument `dis_resamp` because it was added in v2.9.0 and hence | ||
| # after the introduction of the latent projection from v2.4.0: | ||
| if (!any(c("dis_resamp", "...") %in% | ||
| methods::formalArgs(latent_ppd_oscale))) { | ||
| stop("Please add argument `dis_resamp` to the `latent_ppd_oscale` ", | ||
| "function.") | ||
| } | ||
| family$latent_ilink <- latent_ilink | ||
| family$latent_ll_oscale <- latent_ll_oscale | ||
| family$latent_ppd_oscale <- latent_ppd_oscale | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this possibly break existing code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you run reverse-dependency checks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I did. They succeeded. (brms and BayesERtools both do not specify a
latent_ll_oscalefunction, so they are not affected by this PR.)