Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co

## Package Overview

PKPDmap is an R package implementing Maximum A Posteriori (MAP) Bayesian estimation and non-parametric fitting for pharmacokinetic/pharmacodynamic (PK/PD) data. It depends heavily on [PKPDsim](https://github.com/InsightRX/PKPDsim) (also an InsightRX package) for ODE-based PK/PD simulation.
PKPDmap is an R package implementing Maximum A Posteriori (MAP) Bayesian estimation for pharmacokinetic/pharmacodynamic (PK/PD) data. It depends heavily on [PKPDsim](https://github.com/InsightRX/PKPDsim) (also an InsightRX package) for ODE-based PK/PD simulation.

## Common Commands

Expand Down Expand Up @@ -39,8 +39,7 @@ The main entry point is `get_map_estimates()` (`R/get_map_estimates.R`), which s
- `map` — standard MAP Bayesian with empirical Bayes (default)
- `map_flat_prior` — MAP with flattened priors (reduced shrinkage)
- `ls` — Least squares (nearly-flat MAP priors)
- `np` — Non-parametric estimation on a user-supplied parameter matrix
- `np_hybrid` — Hybrid MAP + non-parametric grid search


### Estimation Pipeline

Expand All @@ -52,9 +51,8 @@ get_map_estimates()
│ ├── parse_omega_matrix()
│ ├── parse_error()
│ └── ...
├── mle_wrapper() # wraps optim() + Hessian calculation
│ └── ll_func_PKPDsim() # likelihood: calls PKPDsim, applies error model + censoring
└── get_np_estimates() # for np/np_hybrid methods
└── mle_wrapper() # wraps optim() + Hessian calculation
└── ll_func_PKPDsim() # likelihood: calls PKPDsim, applies error model + censoring
```

### Key Function Roles
Expand All @@ -66,7 +64,6 @@ get_map_estimates()
| `R/ll_func_PKPDsim.R` | Computes log-likelihood by calling PKPDsim and applying residual error + censoring |
| `R/calc_ofv_map.R` | Objective function value for MAP (includes prior penalty) |
| `R/calc_ofv_ls.R` | OFV for least squares |
| `R/get_np_estimates.R` | Non-parametric grid search fitting |
| `R/parse_omega_matrix.R` | Converts various omega input formats to full covariance matrix |
| `R/check_inputs.R` | Comprehensive upfront validation (throws descriptive errors) |
| `R/run_sequential_map.R` | Batch MAP estimation across multiple individuals |
Expand Down
3 changes: 0 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@ S3method(print,map_estimates)
export(calc_ofv_ls)
export(calc_ofv_map)
export(create_block_from_cv)
export(create_grid_around_parameters)
export(create_iov_object)
export(full_to_triangle)
export(get_likelihood_of_data)
export(get_map_estimates)
export(get_np_estimates)
export(join_blocks)
export(ll_func_PKPDsim)
export(lower_triangle_mat_size)
export(map_shrinkage_control)
export(np_settings_default)
export(plot_eta)
export(replace_list_elements)
export(run_sequential_map)
Expand Down
42 changes: 0 additions & 42 deletions R/create_grid_around_parameters.R

This file was deleted.

27 changes: 3 additions & 24 deletions R/get_map_estimates.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#' @param as_eta vector of parameters that are estimates as eta (e.g. IOV)
#' @param weights vector of weights for error. Length of vector should be same
#' as length of observation vector. If NULL (default), all weights are equal.
#' Used in both MAP and NP methods. Note that `weights` argument will also
#' affect residuals (residuals will be scaled too).
#' Note that `weights` argument will also affect residuals (residuals will be
#' scaled too).
#' @param omega between subject variability, supplied as vector specifiying the
#' lower triangle of the covariance matrix of random effects
#' @param weight_prior weighting of priors in relationship to observed data,
Expand Down Expand Up @@ -49,10 +49,7 @@
#' such as `Nelder-Mead` to avoid estimation failures.
#' @param control list of options passed to `optim()` function
#' @param allow_obs_before_dose allow observation before first dose?
#' @param type estimation type, options are `map`, `ls`, and `np_hybrid`
#' @param np_settings list with settings for non-parametric estimation (if
#' selected), containing any of the following: `error`, `grid_span`, grid_size`,
#' `grid_exponential`
#' @param type estimation type, options are `map` and `ls`
#' @param cols column names
#' @param residuals show residuals? This requires an additional simulation so
#' will be slightly slower.
Expand Down Expand Up @@ -127,7 +124,6 @@ get_map_estimates <- function(
control = list(reltol = 1e-5),
allow_obs_before_dose = FALSE,
type = "map",
np_settings = list(),
cols = list(x = "t", y = "y"),
residuals = TRUE,
Comment thread
jasmineirx marked this conversation as resolved.
verbose = FALSE,
Expand Down Expand Up @@ -354,23 +350,6 @@ get_map_estimates <- function(
)
)

#################################################
## Non-parametric estimation (hybrid, based on
## MAP fit as initial estimates)
#################################################
if(type == "np_hybrid") {
obj <- np_fit_wrapper(
obj = obj,
model = model,
regimen = regimen,
lagtime = lagtime,
data = data,
covariates = covariates,
weights = weights,
np_settings = np_settings
)
}

#################################################
## Add g.o.f. info
#################################################
Expand Down
48 changes: 0 additions & 48 deletions R/get_np_estimates.R

This file was deleted.

67 changes: 0 additions & 67 deletions R/np_fit_wrapper.R

This file was deleted.

15 changes: 0 additions & 15 deletions R/np_settings_default.R

This file was deleted.

4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PKPDmap

MAP Bayesian and non-parametric data fitting for PK(PD) models.
MAP Bayesian fitting for PK(PD) models.

## Description

Expand All @@ -9,8 +9,6 @@ This R library implements various methods for fitting of individual PK(PD) data.
- `map`: MAP Bayesian: standard maximum a priori estimation of empirical Bayes estimates
- `map_flat_prior`: MAP Bayesian with flat prior: reduced weight of prior distribution, i.e. will put more trust in the data and hence reduce shrinkage (user can control the weighting).
- `ls`: Least Squares: not *truly* least squares but rather special case of MAP Bayesian with flat priors, i.e. with (almost) fully flat prior.
Comment thread
jasmineirx marked this conversation as resolved.
- `np`: non-parametric estimation. Performs non-parametric estimation based on user-specified parameter matrix of previously studied subjects.
- `np_hybrid`: hybrid MAP and non-parametric extended grid. Will first perform standard MAP estimation (potentially with flattened prior), and subsequently perform non-parametric estimation on grid of support points around MAP estimates.

## Installation

Expand Down
4 changes: 2 additions & 2 deletions man/calc_residuals.Rd

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

2 changes: 1 addition & 1 deletion man/check_inputs.Rd

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

29 changes: 0 additions & 29 deletions man/create_grid_around_parameters.Rd

This file was deleted.

11 changes: 3 additions & 8 deletions man/get_map_estimates.Rd

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

Loading
Loading