nlr: Nonlinear Regression in R

Description Usage Arguments Details Value Author(s) Examples

View source: R/nlr.R

Description

It performs nonlinear regression usually for pharmacokinetic and pharmacodynamic models.

Usage

1
2
nlr(Fx, Data, pNames, IE, LB, UB, Error="A", ObjFx=ObjDef, SecNames, SecForms, 
    Method="L-BFGS-B", Sx)

Arguments

Fx

Function for structural model. It should return a vector of the same length to observations.

Data

Data table which will be used in Fx. Fx should access this with e$DATA.

pNames

Parameter names in the order of Fx arguments

IE

Initial estimates of parameters

LB

Lower bound for optim function. The default value is 0.

UB

Upper bound for optim function. The default value is 1e+06.

Error

Error model. One of "A" for additive error, "POIS" for Poisson error, "P" for proportional error, "C" for combined error model, "S" for general error model. With Error="S", Sx should be provieded.

ObjFx

Objective function to be minimized. The default is maximum likelihood estimation function(-2 log likelihood).

SecNames

Names of secondary parameter estimates

SecForms

Formula to calculate the secondary parameter estimates

Method

"L-BFGS-B" is default. See optim for more detail.

Sx

Scale function. This is usually the inverse of weight. It should return the same length(nrow) of Y. When Error="S", Scale function should be provided as Sx.

Details

This uses scaled transformed parameters and environment e internally.

Value

Est

Point estimate(PE) with standard error(SE) and relative standard error(RSE)

Cov

Variance-covariance matrix of the objective function at the value of point estimates

run$m

Count of positive residuals

run$n

Count of negative residuals

run$run

Count of runs of residuals

run$p.value

P value of run test with excluding zero points

Objective Function Value

Minimum value of the objective function

-2LL

-2 times log likelihood

AIC

Akaike Information Criterion

AICc

Corrected Akaike Information Criterion

BIC

Schwarz Bayesian Information Criterion

Convergence

Convergence code from optim

Message

Message from optim.

Prediction

Fitted(predicted) values

Residuals

Residuals

Scale

Scales with Error="S". Variances for each points are scale vector multiplied by ScaleErrVar in Est.

Elapsed Time

Consumed time by minimization

Author(s)

Kyun-Seop Bae <k@acr.kr>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
tData = Theoph
colnames(tData) = c("ID", "BWT", "DOSE", "TIME", "DV")

fPK = function(THETA) # Prediction function
{
  DOSE = 320000 # in microgram
  TIME = e$DATA[,"TIME"] # use data in e$DATA

  K    = THETA[1]
  Ka   = THETA[2]
  V    = THETA[3]

  P  = DOSE/V*Ka/(Ka - K) * (exp(-K*TIME) - exp(-Ka*TIME))
  return(P)
}

IDs = unique(tData[,"ID"])
nID = length(IDs)
for (i in 1:nID) {
  Data = tData[tData$ID == IDs[i],]
  Res = nlr(fPK, Data, pNames=c("k", "ka", "V"), IE=c(0.1, 3, 500), 
            SecNames=c("CL", "Thalf", "MRT"), SecForms=c(~V*k, ~log(2)/k, ~1/k))
  print(paste("## ID =", i, "##"))
  print(Res)
}

wnl documentation built on Aug. 28, 2020, 1:11 a.m.