Skip to content

Commit

Permalink
bug fix for Jackknife.
Browse files Browse the repository at this point in the history
test fixes.
  • Loading branch information
halpo committed Oct 7, 2024
1 parent 3d362bf commit 5fe98f8
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
3 changes: 2 additions & 1 deletion R/SIDR_Ravinew.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ SIDR_Ravinew <- function(X, Y,
}else
{
initial <- as.vector(initial)
initial <- initial/initial[1]
if(initial[1] != 0)
initial <- initial/initial[1]
}

if (is.null(bandwidth))
Expand Down
3 changes: 1 addition & 2 deletions R/jackknife.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ cross_validate <- function(original.object, progress = interactive()){
alpha = original.object$alpha,
intensity.covariates = attr(original.object$intensity.model, 'additional.covariates'),
outcome.covariates = attr(original.object$outcome.model, 'additional.covariates'),
End = original.object$End,
control = original.object$control
End = original.object$End
) |>
prune_bootstrap_replication()
}
Expand Down
13 changes: 9 additions & 4 deletions R/sim_outcome_modeler.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
#'
#' @param formula The outcome model formula
#' @param data The data to fit the outcome model to.
#' Should only include follow-up data, i.e. time > 0.
#' @param kernel The kernel to use for the outcome model.
#' @param method The optimization method to use for the outcome model, either "optim", "nlminb", or "nmk".
#' @param ... Currently ignored, included for future compatibility.
#'
#' @return Object of class `PCORI::Single-index-outcome-model` which contains the outcome model portion.
#' @export
PCORI_sim_outcome_modeler <-
function(formula, data, kernel = "K2_Biweight", method = "nmk", ...){
fu.data <- filter(data, ..time.. > 0)
mf <- model.frame(formula, data = fu.data, id = ..id..)
function(formula, data, kernel = "K2_Biweight", method = "nmk", id = ..id.., ...){
id <- ensym(id)
mf <- rlang::inject(model.frame(formula, data = data, id = !!id))
Xi <- model.matrix(formula, data = mf)

Yi <- model.response(mf)
Expand Down Expand Up @@ -47,11 +48,15 @@ function(formula, data, kernel = "K2_Biweight", method = "nmk", ...){
`model.matrix.PCORI::Single-index-outcome-model` <-
function(object, data = model.frame(object), ...){
model.matrix(terms(object), data = data, ...)
}#' @export
}
#' @export
`formula.PCORI::Single-index-outcome-model` <-
function(x, ...){
as.formula(terms(x))
}
#' @export
`coef.PCORI::Single-index-outcome-model` <-
function(x, ...)x$coef

#' @export
`predict.PCORI::Single-index-outcome-model` <-
Expand Down
4 changes: 3 additions & 1 deletion man/PCORI_sim_outcome_modeler.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/testthat/test-influence_term1.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ test_that("Compute Influence term1 old vs. new methods", {
ns(prev_outcome, df=3) +
scale(Time) +
scale(delta_time) - 1,
id = Subject_ID,
data = followup.data)


Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-influence_term2.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ test_that("Compute Influence term2 old vs. new methods", {
ns(prev_outcome, df=3) +
scale(Time) +
scale(delta_time) - 1,
id = Subject_ID,
data = followup.data)


Expand Down

0 comments on commit 5fe98f8

Please sign in to comment.