Skip to content

Commit 963f430

Browse files
authored
Merge pull request #63 from InsightRX/rm_np_fitting
remove non-parametric fitting method
2 parents ce1f15e + 7ced3ed commit 963f430

18 files changed

Lines changed: 20 additions & 347 deletions

CLAUDE.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
44

55
## Package Overview
66

7-
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.
7+
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.
88

99
## Common Commands
1010

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

4544
### Estimation Pipeline
4645

@@ -52,9 +51,8 @@ get_map_estimates()
5251
│ ├── parse_omega_matrix()
5352
│ ├── parse_error()
5453
│ └── ...
55-
├── mle_wrapper() # wraps optim() + Hessian calculation
56-
│ └── ll_func_PKPDsim() # likelihood: calls PKPDsim, applies error model + censoring
57-
└── get_np_estimates() # for np/np_hybrid methods
54+
└── mle_wrapper() # wraps optim() + Hessian calculation
55+
└── ll_func_PKPDsim() # likelihood: calls PKPDsim, applies error model + censoring
5856
```
5957

6058
### Key Function Roles
@@ -66,7 +64,6 @@ get_map_estimates()
6664
| `R/ll_func_PKPDsim.R` | Computes log-likelihood by calling PKPDsim and applying residual error + censoring |
6765
| `R/calc_ofv_map.R` | Objective function value for MAP (includes prior penalty) |
6866
| `R/calc_ofv_ls.R` | OFV for least squares |
69-
| `R/get_np_estimates.R` | Non-parametric grid search fitting |
7067
| `R/parse_omega_matrix.R` | Converts various omega input formats to full covariance matrix |
7168
| `R/check_inputs.R` | Comprehensive upfront validation (throws descriptive errors) |
7269
| `R/run_sequential_map.R` | Batch MAP estimation across multiple individuals |

NAMESPACE

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,14 @@ S3method(print,map_estimates)
44
export(calc_ofv_ls)
55
export(calc_ofv_map)
66
export(create_block_from_cv)
7-
export(create_grid_around_parameters)
87
export(create_iov_object)
98
export(full_to_triangle)
109
export(get_likelihood_of_data)
1110
export(get_map_estimates)
12-
export(get_np_estimates)
1311
export(join_blocks)
1412
export(ll_func_PKPDsim)
1513
export(lower_triangle_mat_size)
1614
export(map_shrinkage_control)
17-
export(np_settings_default)
1815
export(plot_eta)
1916
export(replace_list_elements)
2017
export(run_sequential_map)

R/create_grid_around_parameters.R

Lines changed: 0 additions & 42 deletions
This file was deleted.

R/get_map_estimates.R

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#' @param as_eta vector of parameters that are estimates as eta (e.g. IOV)
99
#' @param weights vector of weights for error. Length of vector should be same
1010
#' as length of observation vector. If NULL (default), all weights are equal.
11-
#' Used in both MAP and NP methods. Note that `weights` argument will also
12-
#' affect residuals (residuals will be scaled too).
11+
#' Note that `weights` argument will also affect residuals (residuals will be
12+
#' scaled too).
1313
#' @param omega between subject variability, supplied as vector specifiying the
1414
#' lower triangle of the covariance matrix of random effects
1515
#' @param weight_prior weighting of priors in relationship to observed data,
@@ -49,10 +49,7 @@
4949
#' such as `Nelder-Mead` to avoid estimation failures.
5050
#' @param control list of options passed to `optim()` function
5151
#' @param allow_obs_before_dose allow observation before first dose?
52-
#' @param type estimation type, options are `map`, `ls`, and `np_hybrid`
53-
#' @param np_settings list with settings for non-parametric estimation (if
54-
#' selected), containing any of the following: `error`, `grid_span`, grid_size`,
55-
#' `grid_exponential`
52+
#' @param type estimation type, options are `map` and `ls`
5653
#' @param cols column names
5754
#' @param residuals show residuals? This requires an additional simulation so
5855
#' will be slightly slower.
@@ -127,7 +124,6 @@ get_map_estimates <- function(
127124
control = list(reltol = 1e-5),
128125
allow_obs_before_dose = FALSE,
129126
type = "map",
130-
np_settings = list(),
131127
cols = list(x = "t", y = "y"),
132128
residuals = TRUE,
133129
verbose = FALSE,
@@ -354,23 +350,6 @@ get_map_estimates <- function(
354350
)
355351
)
356352

357-
#################################################
358-
## Non-parametric estimation (hybrid, based on
359-
## MAP fit as initial estimates)
360-
#################################################
361-
if(type == "np_hybrid") {
362-
obj <- np_fit_wrapper(
363-
obj = obj,
364-
model = model,
365-
regimen = regimen,
366-
lagtime = lagtime,
367-
data = data,
368-
covariates = covariates,
369-
weights = weights,
370-
np_settings = np_settings
371-
)
372-
}
373-
374353
#################################################
375354
## Add g.o.f. info
376355
#################################################

R/get_np_estimates.R

Lines changed: 0 additions & 48 deletions
This file was deleted.

R/np_fit_wrapper.R

Lines changed: 0 additions & 67 deletions
This file was deleted.

R/np_settings_default.R

Lines changed: 0 additions & 15 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# PKPDmap
22

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

55
## Description
66

@@ -9,8 +9,6 @@ This R library implements various methods for fitting of individual PK(PD) data.
99
- `map`: MAP Bayesian: standard maximum a priori estimation of empirical Bayes estimates
1010
- `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).
1111
- `ls`: Least Squares: not *truly* least squares but rather special case of MAP Bayesian with flat priors, i.e. with (almost) fully flat prior.
12-
- `np`: non-parametric estimation. Performs non-parametric estimation based on user-specified parameter matrix of previously studied subjects.
13-
- `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.
1412

1513
## Installation
1614

man/calc_residuals.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/check_inputs.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)