lmcal: Perform linear and nonlinear calibration of analytical method

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

Fit given calibration data to several regression models.

Usage

1
2
lmcal(x, y, confint = 0.95, gridratio = 0.05)
nlscal(x, y, confint = 0.95, gridratio = 0.05)

Arguments

x

a vector of standard concentrations

y

a vector of corresponding respondes (peak areas etc.)

confint

confidence interval for graphing prediction intervals

gridratio

a part of x variable range, to extend plot range (default 5 percent)

Details

For linear 'lmcal' fitting, procedure is performed as follows. First, the calibration data are fitted to OLS linear, quadratic, cubical, and 4th order polynomial. These models are called p1 - p4. Next, linear model is reweighted using x and y raised to power gamma from range (-4,4) with 0.1 accuracy. The optimal weights are detected by minimal mean relative error (MRE) according to Almeida et al. (2002). The best weighting scheme is then chosen, and data are fit to the same equations (called P1-P4, with uppercase).

Next, the optimal value of lambda for Box-Cox transform is estimated with accuracy up to 0.001, for transformation of x and y. The transformed models are then fitted (called bx and by).

Then, two next log-log transformed models, are fitted - linear called l1, and quadratic (mentioned sometimes as Wagner transform), called l2.

Last, the same models as p1 - p4 and P1 - P4, are fitted using rlm robust method, and called r1 - r4 and R1 - R4.

This function performs also computation of grid and corresponding predicted values for easy graphing of fitted models.

For nonlinear 'nlscal' fitting, procedure is performed as above, but there are following models fitted: asymptotic (a1), asymptotic through origin (a2), logistic (g1), four parameter logistic (g2), Michaelis-Menten (m1) and nonparametric (loess) spline (s1). There are no weighting nor transform when fitting by 'nlscal'.

Value

Returns object of class c("lmcal","cal") or c("nlscal","cal"), which is the list of following components:

models

A list of fitted models (p1-p4,P1-P4,l1,l2,bx,by,r1-r4,R1-R4)

graph

A list used by plot() method to produce graphs. Stored permanently to make custom graphing easier. Containing following elements: grid - a grid of x values, fitted - corresponding fitted values, upperc,lowerc - upper and lower bound for interval="confidence" prediction, upperp,lowerp - upper and lower bound for interval="prediction" prediction

x

Concentration vector

y

Response vector

Linear calibration object contains also following elements:

weigh

A dataframe containing sequence of gamma values and corresponding mean relative errors, estimated during weighting process

wx

Value of gamma for oprimal weighting on x

wy

Value of gamma for oprimal weighting on y

yw

Logical, if weighting on y gives better result than on x

px

Optimal Box-Cox power for transform of x variable

py

Optimal Box-Cox power for transform of y variable

Note

This function performs *no* decision which model should be chosen! Such decision should be always made by analyst.

Author(s)

Lukasz Komsta

References

Almeida, A.M., Castel-Branco, M.M., Falcao, A.C. (2002) Linear regression for calibration lines revisited: weighting schemes for bioanalytical methods. J. Chromatogr. B Biomed. Sci. Appl. 774, 215-222.

Nagaraja, N.V., Paliwal, J.K., Gupta, R.C. (1999) Choosing the calibration model in assay validation. J. Pharm. Biomed. Anal. 20, 433-438.

Kimanani, E.K., Lavigne, J. (1998) Bioanalytical calibration curves: variability of optimal powers between and within analytical methods. J. Pharm. Biomed. Anal. 16, 1107-1115.

Kirkup, L., Mulholland, M. (2004). Comparison of linear and non-linear equations in univariate calibration. J. Chromatogr. A, 1029, 1-11.

Kimanani, E.K. (1998) Bioanalitical calibration curves: proposal for statistical criteria. J. Pharm. Biomed. Anal. 16, 1117-1124.

Baumann, K., Waetzig, H. (1997) Regression and calibration for analytical separation techniques. Part I. Design considerations. Process Control and Quality, 10, 59-73.

Baumann, K. (1997) Regression and calibration for analytical separation techniques. Part II. Validation, weighted and robust regression. Process Control and Quality, 10, 75-112.

Coleman, D.E., Vanatta, L.E. (1999) Lack-of-fit testing of ion chromatographic calibration curves with inexact replicates. J. Chromatogr. A 850, 43-51.

See Also

lm, rlm, boxcox

Examples

1
2
3
4
5
data(ibuprofen)
attach(ibuprofen)
fit = lmcal(conc,area)
fit
summary(fit)

Example output

Loading required package: MASS
Loading required package: outliers
------------------------------------------
If you use this package, please cite the recent paper containing description of this software:
Komsta, L. Chemometric and statistical evaluation of calibration curves in pharmaceutical analysis 
           - a short review on trends and recommendations. J. AOAC Int. 2012, 95, 3, 669-672.
------------------------------------------
There were 12 warnings (use warnings() to see them)

Optimal Box-Cox power on x: 1.0706
Optimal Box-Cox power on y: 0.9286

Optimal power of weighting on x: -1.1
Optimal power of weighting on y: -1.2
Better weighting on y: TRUE 

Coefficients:
            x0          x1          x2          x3    x4
p1  7.1855e+03  2.4367e+03          NA          NA    NA
p2  2.4477e+04  2.2503e+03  4.5050e-01          NA    NA
p3  6.6297e+03  2.5568e+03 -1.1670e+00  2.6549e-03    NA
p4  8.4946e+04  7.8408e+02  1.3075e+01 -4.5838e-02 1e-04
P1  9.2852e+03  2.4262e+03          NA          NA    NA
P2  2.3786e+04  2.2577e+03  4.3268e-01          NA    NA
P3  1.5885e+04  2.3970e+03 -3.2048e-01  1.2613e-03    NA
P4  9.9514e+04  4.5237e+02  1.5754e+01 -5.5003e-02 1e-04
l1  3.4461e+00  9.7722e-01          NA          NA    NA
l2  3.9466e+00  5.3114e-01  9.8918e-02          NA    NA
bx  3.9029e+04  1.6761e+03          NA          NA    NA
by  1.6991e+04  9.5547e+02          NA          NA    NA
r1  6.2176e+03  2.4397e+03          NA          NA    NA
r2  6.5589e+04  1.9082e+03  1.1374e+00          NA    NA
r3 -6.1566e+04  3.5305e+03 -5.6390e+00  9.2702e-03    NA
r4  1.8125e+05 -1.7845e+03  3.7062e+01 -1.3975e-01 2e-04
R1  6.9505e+03  2.4359e+03          NA          NA    NA
R2  6.3203e+04  1.9285e+03  1.0957e+00          NA    NA
R3 -6.6491e+04  3.6044e+03 -5.9925e+00  9.8112e-03    NA
R4  1.7885e+05 -1.7263e+03  3.6555e+01 -1.3787e-01 2e-04

Goodness of fit:
         R-Sq   Adj-R-Sq        AIC     Sigma
p1    0.99981    0.99979  261.75205 2421.4910
p2    0.99994    0.99993  247.71781 1426.5197
p3    0.99995    0.99993  247.49803 1382.1149
p4    0.99996    0.99995  244.32234 1211.0032
P1    0.99980    0.99978  262.44697    0.9726
P2    0.99992    0.99991  250.87610    0.6256
P3    0.99993    0.99990  252.49472    0.6473
P4    0.99995    0.99992  249.93419    0.5798
l1    0.99968    0.99965 -120.27937    0.0029
l2    0.99990    0.99988 -134.86012    0.0017
bx    0.99993    0.99993  246.70642 1414.8727
by    0.99993    0.99993  220.63859  557.6887
r1         NA         NA  262.21028 1641.7947
r2         NA         NA  290.09308 1481.8118
r3         NA         NA  276.52142  916.3124
r4         NA         NA  291.36478  676.5453
R1         NA         NA  264.54576    0.7086
R2         NA         NA  297.47919    0.5314
R3         NA         NA  287.70642    0.3199
R4         NA         NA  284.47973    0.2587

Optimal Box-Cox power on x: 1.0706
Optimal Box-Cox power on y: 0.9286

Optimal power of weighting on x: -1.1
Optimal power of weighting on y: -1.2

Mean relative error:
 0.003800207 on x
 0.003778024 on y
 0.003999273 unweighted

Better weighting on y: TRUE 

Coefficients:
         Estimate  Std. Error     t value  Pr(>|t|)    
x0 P1   9285.2032   1865.6239      4.9770 0.0003215 ***
x0 P2  23785.8581   3622.5547      6.5660 4.046e-05 ***
x0 P3  15884.8049  15495.0837      1.0252 0.3294508    
x0 P4  99514.3329  47017.7766      2.1165 0.0633944 .  
x0 R1   6950.5171   1654.4969      4.2010 2.658e-05 ***
x0 R2  63203.4992   1746.3796     36.1912 < 2.2e-16 ***
x0 R3 -66491.1832   5816.9866    -11.4305 < 2.2e-16 ***
x0 R4 178849.2739  12441.3020     14.3754 < 2.2e-16 ***
x0 bx  39029.0998   1150.3645     33.9276 2.733e-13 ***
x0 by  16991.1734    481.2495     35.3064 1.702e-13 ***
x0 l1      3.4461      0.0116    297.8942 < 2.2e-16 ***
x0 l2      3.9466      0.1004     39.2999 3.508e-13 ***
x0 p1   7185.5156   2089.5912      3.4387 0.0049061 ** 
x0 p2  24476.5774   3767.7857      6.4963 4.450e-05 ***
x0 p3   6629.6786  14096.2525      0.4703 0.6482197    
x0 p4  84946.0666  40940.9648      2.0748 0.0678297 .  
x0 r1   6217.5759   2299.2674      2.7042 0.0068478 ** 
x0 r2  65588.9586   2189.9951     29.9494 < 2.2e-16 ***
x0 r3 -61566.2330   7037.2999     -8.7486 < 2.2e-16 ***
x0 r4 181251.9827  13538.4495     13.3879 < 2.2e-16 ***
x1 P1   2426.2468      9.9272    244.4036 < 2.2e-16 ***
x1 P2   2257.7038     40.2376     56.1093 7.112e-15 ***
x1 P3   2397.0219    268.3580      8.9322 4.429e-06 ***
x1 P4    452.3725   1071.8938      0.4220 0.6829048    
x1 R1   2435.8586      8.8038    276.6832 < 2.2e-16 ***
x1 R2   1928.5087     19.3980     99.4182 < 2.2e-16 ***
x1 R3   3604.3647    100.7439     35.7775 < 2.2e-16 ***
x1 R4  -1726.2560    283.6322     -6.0862 1.156e-09 ***
x1 bx   1676.1184      3.9161    428.0083 < 2.2e-16 ***
x1 by    955.4713      2.2442    425.7567 < 2.2e-16 ***
x1 l1      0.9772      0.0051    193.3863 < 2.2e-16 ***
x1 l2      0.5311      0.0893      5.9447 9.666e-05 ***
x1 p1   2436.7245      9.7442    250.0686 < 2.2e-16 ***
x1 p2   2250.3211     38.8158     57.9744 4.969e-15 ***
x1 p3   2556.7962    236.8145     10.7966 7.840e-07 ***
x1 p4    784.0799    907.5734      0.8639 0.4100597    
x1 r1   2439.7193     10.7220    227.5435 < 2.2e-16 ***
x1 r2   1908.1636     22.5614     84.5766 < 2.2e-16 ***
x1 r3   3530.5491    118.2254     29.8629 < 2.2e-16 ***
x1 r4  -1784.4548    300.1184     -5.9458 2.750e-09 ***
x2 P2      0.4327      0.1020      4.2425 0.0013831 ** 
x2 P3     -0.3205      1.4371     -0.2230 0.8280176    
x2 P4     15.7540      8.7301      1.8046 0.1046309    
x2 R2      1.0957      0.0492     22.2859 < 2.2e-16 ***
x2 R3     -5.9925      0.5395    -11.1077 < 2.2e-16 ***
x2 R4     36.5554      2.3100     15.8245 < 2.2e-16 ***
x2 l2      0.0989      0.0198      4.9954 0.0004055 ***
x2 p2      0.4505      0.0928      4.8556 0.0005062 ***
x2 p3     -1.1670      1.2373     -0.9432 0.3677970    
x2 p4     13.0751      7.1807      1.8209 0.1019624    
x2 r2      1.1374      0.0539     21.0926 < 2.2e-16 ***
x2 r3     -5.6390      0.6177     -9.1293 < 2.2e-16 ***
x2 r4     37.0616      2.3745     15.6080 < 2.2e-16 ***
x3 P3      0.0013      0.0024      0.5255 0.6106812    
x3 P4     -0.0550      0.0303     -1.8153 0.1028663    
x3 R3      0.0098      0.0009     10.8887 < 2.2e-16 ***
x3 R4     -0.1379      0.0080    -17.1958 < 2.2e-16 ***
x3 p3      0.0027      0.0020      1.3108 0.2192314    
x3 p4     -0.0458      0.0242     -1.8915 0.0911248 .  
x3 r3      0.0093      0.0010      9.1678 < 2.2e-16 ***
x3 r4     -0.1397      0.0080    -17.4378 < 2.2e-16 ***
x4 P4      0.0001      0.0000      1.8616 0.0955657 .  
x4 R4      0.0002      0.0000     18.7017 < 2.2e-16 ***
x4 p4      0.0001      0.0000      2.0064 0.0757681 .  
x4 r4      0.0002      0.0000     19.4460 < 2.2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residuals:
            0%         25%         50%         75%        100%           W
p1  -3411.2350   -956.2609   -633.8371    675.2061   4691.8080      0.8997
p2  -1791.1304  -1110.4795   -185.7831   1364.0765   1904.8696      0.8774
p3  -1653.4307   -953.4773   -287.4505    904.7724   2392.5513      0.9501
p4  -1709.4648   -668.0869    192.0693    673.1431   1986.5352      0.9720
P1  -3206.8646  -1398.9152   -530.8360    -19.7872   4901.1638      0.8633
P2  -1675.1390  -1096.8205   -140.9642   1303.0759   2020.8610      0.8798
P3  -1533.4564  -1038.8358   -260.8895   1144.0320   2162.5436      0.8972
P4  -1766.8812   -702.0159     89.2569    710.3186   1929.1188      0.9638
l1     -0.0028     -0.0021     -0.0010      0.0005      0.0066      0.8638
l2     -0.0027     -0.0010     -0.0002      0.0011      0.0034      0.9562
bx  -1876.4174  -1214.4929    -38.1910   1368.0099   1819.5826      0.8834
by   -756.9503   -463.0558    -23.7449    533.4825    759.1336      0.8932
r1  -3101.8541   -795.0184   -174.4162   1274.9338   5348.5869      0.9228
r2 -14769.0697  -5811.0169   -363.8833    -38.3051   1271.6388      0.7286
r3  -1084.6571   -157.4836    186.7870    420.2634  10272.1227      0.5976
r4 -14008.3794   -199.7239    -69.2792    133.9334   3682.5651      0.5809
R1  -2985.8187   -567.9099   -251.8039   1016.6706   5016.7765      0.8930
R2 -14047.1060  -5558.1056   -349.6547    -96.1537   1255.7213      0.7334
R3  -1052.9120   -135.2842    121.7895    517.0114  10736.4510      0.5918
R4 -13802.8794   -191.1081    -73.5248    125.5459   3689.5663      0.5829
      Pr(<W)    
p1 0.1115569    
p2 0.0533595 .  
p3 0.5617375    
p4 0.9018410    
P1 0.0337856 *  
P2 0.0576933 .  
P3 0.1025857    
P4 0.7850142    
l1 0.0343363 *  
l2 0.6603242    
bx 0.0649205 .  
by 0.0898782 .  
r1 0.2412125    
r2 0.0007420 ***
r3 3.864e-05 ***
r4 2.753e-05 ***
R1 0.0893096 .  
R2 0.0008371 ***
R3 3.431e-05 ***
R4 2.866e-05 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Variances:
               Min     Median        Max      K   Pr(>K)   
Pure       2380.50  186660.50 6830208.00 12.297 0.055653 . 
Log           0.00       0.00       0.00 17.741 0.006914 **
Box-Cox     371.52   28344.99 1149255.19 12.650 0.048946 * 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Goodness of fit:
         R-Sq   Adj-R-Sq        AIC      Sigma        SSR       SSPE       F
p1    0.99981    0.99979  261.75205 2.4215e+03 7.0363e+07 7.9093e+06 11.0548
p2    0.99994    0.99993  247.71781 1.4265e+03 2.2385e+07 7.9093e+06  3.2028
p3    0.99995    0.99993  247.49803 1.3821e+03 1.9102e+07 7.9093e+06  3.3021
p4    0.99996    0.99995  244.32234 1.2110e+03 1.3199e+07 7.9093e+06  2.3407
P1    0.99980    0.99978  262.44697 9.7260e-01 1.1351e+01 7.9093e+06      NA
P2    0.99992    0.99991  250.87610 6.2560e-01 4.3057e+00 7.9093e+06      NA
P3    0.99993    0.99990  252.49472 6.4730e-01 4.1900e+00 7.9093e+06      NA
P4    0.99995    0.99992  249.93419 5.7980e-01 3.0251e+00 7.9093e+06      NA
l1    0.99968    0.99965 -120.27937 2.9000e-03 1.0000e-04 0.0000e+00  5.8256
l2    0.99990    0.99988 -134.86012 1.7000e-03 0.0000e+00 0.0000e+00  1.0133
bx    0.99993    0.99993  246.70642 1.4149e+03 2.4022e+07 7.9093e+06  2.8521
by    0.99993    0.99993  220.63859 5.5769e+02 3.7322e+06 1.3106e+06  2.5867
r1         NA         NA  262.21028 1.6418e+03 7.2705e+07 7.9093e+06      NA
r2         NA         NA  290.09308 1.4818e+03 4.6182e+08 7.9093e+06      NA
r3         NA         NA  276.52142 9.1631e+02 1.5185e+08 7.9093e+06      NA
r4         NA         NA  291.36478 6.7655e+02 3.8005e+08 7.9093e+06      NA
R1         NA         NA  264.54576 7.0860e-01 1.3187e+01 7.9093e+06      NA
R2         NA         NA  297.47919 5.3140e-01 1.2015e+02 7.9093e+06      NA
R3         NA         NA  287.70642 3.1990e-01 5.1822e+01 7.9093e+06      NA
R4         NA         NA  284.47973 2.5870e-01 3.5676e+01 7.9093e+06      NA
     Pr(>F)   
p1 0.003222 **
p2 0.085570 . 
p3 0.087435 . 
p4 0.166576   
P1       NA   
P2       NA   
P3       NA   
P4       NA   
l1 0.019460 * 
l2 0.461544   
bx 0.102212   
by 0.123754   
r1       NA   
r2       NA   
r3       NA   
r4       NA   
R1       NA   
R2       NA   
R3       NA   
R4       NA   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Sensitivity and autocorrelation:
      Sens     LOD     LOQ    Auto      DW  Pr(<DW)   
p1  0.9937  3.2794  9.9375  0.0939 1.38728 0.077872 . 
p2  0.6339  2.0919  6.3392 -0.1521 2.13482 0.445225   
p3  0.5406  1.7839  5.4057 -0.2232 2.14595 0.450685   
p4  1.5445  5.0968 15.4449 -0.1887 2.04487 0.420956   
P1  0.0004  0.0013  0.0040  0.0418 1.54238 0.134268   
P2  0.0003  0.0009  0.0028 -0.1701 2.14728 0.454901   
P3  0.0003  0.0009  0.0027 -0.1870 2.13902 0.445513   
P4  0.0013  0.0042  0.0128 -0.2006 2.07907 0.444676   
l1      NA      NA      NA  0.0226 1.41554 0.087374 . 
l2      NA      NA      NA -0.1287 1.88321 0.271245   
bx      NA      NA      NA -0.1422 2.13281 0.533920   
by      NA      NA      NA -0.1441 2.12070 0.524305   
r1  0.6729  2.2207  6.7294  0.1021 1.28980 0.053014 . 
r2  0.7766  2.5627  7.7656  0.4207 0.89283 0.005037 **
r3  0.2595  0.8565  2.5954  0.0000 1.30219 0.043064 * 
r4 -0.3791 -1.2511 -3.7913  0.0018 1.44432 0.104051   
R1  0.0003  0.0010  0.0029  0.0724 1.35904 0.069900 . 
R2  0.0003  0.0009  0.0028  0.4162 0.90904 0.005519 **
R3  0.0001  0.0003  0.0009  0.0006 1.30923 0.044293 * 
R4 -0.0001 -0.0005 -0.0015  0.0014 1.44412 0.103986   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

quantchem documentation built on May 30, 2017, 5:28 a.m.

Related to lmcal in quantchem...