Last data update: 2014.03.03

R: Advanced Tools for Metrology
ATmet-packageR Documentation

Advanced Tools for Metrology

Description

This package provides functions for smart sampling and sensitivity analysis for metrology applications, including computationally expensive problems.

Details

Package: ATmet
Type: Package
Version: 1.2
Date: 2014-01-06
License: GPL-3

The function for smart sampling implements the Latin Hypercube Sampling (LHS) method using the lhs package. The functions for sensitivity analysis implement the Standardized Rank Regression Coefficient (SRRC) and the Sobol' sensitivity indices using the sensitivity package. These methods can be used for computationally expensive problems.

Note

This work is part of a joint research project within the European Metrology Research Programme (EMRP) called "Novel Mathematical and Statistical Approaches to Uncertainty Evaluation". The EMRP is jointly funded by the EMRP participating countries within EURAMET and the European Union.

Author(s)

Severine Demeyer and Alexandre Allard

Maintainer: severine.demeyer@lne.fr alexandre.allard@lne.fr

See Also

lhs

sensitivity

Examples

# **********************
# Smart sampling method
# **********************

N<- 100
  k<- 4
  x<- list("X1","X2","X3","X4")
  distrib<- list("norm","norm","unif","t.scaled")
  distrib.pars<- list(list(0,2),list(0,1),list(20,150),list(2,0,1))
  LHSdesign(N,k,distrib,distrib.pars,x)
  
# **********************
# Sensitivity analysis
# **********************
  
##Simulate the input sample
M=10000
Xmass <- data.frame(X1 = rnorm(M, 100, 5e-5),
                    X2 = rnorm(M, 0.001234, 2e-5),
                    X3 = runif(M, 1100, 1300),
                    X4 = runif(M,7000000,9000000),
                    X5 = runif(M,7950000,8050000))#Data-frame

#Define the measurement model (GUM-S1, 9.3)
calibMass <-function(x){
  return(((x[,1]+x[,2])*(1+(x[,3]-1200)*(1/x[,4]-1/x[,5]))-100)*1e3)
}

#####   Use SRRC with a model function    #####
#Apply sensitivityMet function to evaluate the associated SRRC indices
S_SRRC=sensitivityMet(model=calibMass,x=Xmass, nboot=100, method="SRRC", conf=0.95)
##Print the results
#First order indices
S_SRRC$S1

#####   Use Sobol with a computational code   #####
#Creation of the design for the computation of Sobol sensitivity indices
S_Sobol=sensitivityMet(model=NULL,x=Xmass,y=NULL, nboot=100, method="Sobol", conf=0.95)

#Obtain the design of experiment to submit to the code
XDesign=S_Sobol$SI$X

#Run the computational code with XDesign as a sample of the input quantities
#We use calibMass function (see GUM-S1) as an example
YDesign=calibMass(XDesign)

#Run the Sobol indices calculations with the outputs of the code
S_Sobol$SI=tell(x=S_Sobol$SI,y=YDesign)

##Print the results
#First order indices
S_Sobol$SI$S
#Total order indices
S_Sobol$SI$T 
  

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(ATmet)
Loading required package: DiceDesign
Loading required package: lhs
Loading required package: metRology

Attaching package: 'metRology'

The following objects are masked from 'package:base':

    cbind, rbind

Loading required package: msm
Loading required package: sensitivity
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/ATmet/ATmet-package.Rd_%03d_medium.png", width=480, height=480)
> ### Name: ATmet-package
> ### Title: Advanced Tools for Metrology
> ### Aliases: ATmet-package ATmet
> ### Keywords: latin hypercube sampling, srrc, sobol
> 
> ### ** Examples
> 
> # **********************
> # Smart sampling method
> # **********************
> 
> N<- 100
>   k<- 4
>   x<- list("X1","X2","X3","X4")
>   distrib<- list("norm","norm","unif","t.scaled")
>   distrib.pars<- list(list(0,2),list(0,1),list(20,150),list(2,0,1))
>   LHSdesign(N,k,distrib,distrib.pars,x)
$design.unif
              X1         X2          X3          X4
1   0.3424417256 0.50472909 0.871766043 0.783954901
2   0.3339423092 0.27899971 0.695144303 0.349169384
3   0.4373111968 0.62364693 0.150598084 0.038266540
4   0.5864990913 0.00371262 0.500150364 0.861234695
5   0.8279481255 0.53625902 0.803831943 0.617346938
6   0.1086992889 0.36938351 0.330830746 0.983673346
7   0.6213565291 0.30677383 0.867086547 0.851026693
8   0.9015851777 0.09734878 0.044126491 0.440239897
9   0.1273261207 0.20143358 0.576838447 0.234828678
10  0.0706259419 0.98507555 0.763812443 0.516938239
11  0.9426640572 0.51119500 0.994631171 0.454452281
12  0.5329191380 0.63363136 0.273243076 0.084077340
13  0.8971868747 0.08954993 0.705829414 0.563294607
14  0.6777687008 0.10637854 0.119764243 0.074533742
15  0.3190767963 0.07229899 0.845743425 0.305651719
16  0.5037163439 0.14445511 0.622967839 0.117397265
17  0.4666526607 0.83490183 0.175297026 0.649367305
18  0.7398308255 0.01192848 0.311757036 0.220422588
19  0.5261288689 0.86929938 0.853683691 0.933306122
20  0.3958107726 0.34530246 0.031870265 0.905528740
21  0.6946068476 0.37859347 0.724219763 0.261882069
22  0.2219827211 0.82884582 0.399948826 0.598960665
23  0.1764753200 0.16136434 0.895950336 0.556269834
24  0.7452956499 0.39964481 0.084497143 0.603716337
25  0.3813351599 0.49689003 0.902186247 0.335459814
26  0.2608044322 0.65464643 0.005301037 0.205088579
27  0.3223037969 0.35290676 0.404220871 0.286064783
28  0.2546947459 0.41607168 0.077395067 0.801541858
29  0.0437164787 0.12349911 0.421519061 0.364078102
30  0.2724888802 0.87093159 0.788963199 0.027104148
31  0.2376656166 0.56414619 0.658538521 0.954973771
32  0.9238579187 0.33898547 0.381600436 0.879991935
33  0.8772866722 0.05549196 0.717745259 0.813045100
34  0.4286422260 0.60138579 0.738158000 0.068695971
35  0.5707062936 0.19721657 0.683031136 0.658846504
36  0.4768897076 0.29750637 0.018183707 0.212662508
37  0.6371429364 0.45763382 0.053020496 0.370378317
38  0.0199212394 0.72800488 0.142282270 0.137810577
39  0.2475708546 0.31163970 0.881467421 0.923791109
40  0.3644146897 0.18518496 0.677830315 0.975355190
41  0.7838922718 0.06878843 0.190461269 0.421085626
42  0.5514012448 0.21888865 0.515311144 0.661652378
43  0.2851686155 0.77860320 0.747852110 0.965063008
44  0.1677636069 0.66057933 0.452698575 0.730945442
45  0.4598693967 0.55423840 0.064438153 0.674460652
46  0.5408829075 0.74119626 0.522693209 0.726817249
47  0.7026387433 0.71772946 0.565189262 0.995822662
48  0.7256841156 0.85094620 0.251042211 0.828891745
49  0.2199409991 0.79251521 0.913100954 0.469552743
50  0.5119878301 0.81308178 0.357415786 0.948433795
51  0.0557410126 0.67520208 0.436481649 0.434527605
52  0.6174477299 0.61936434 0.636820348 0.105807551
53  0.6074225209 0.97094702 0.536531755 0.163270666
54  0.1314669852 0.42160411 0.979917461 0.245226491
55  0.1178107388 0.89798747 0.758560508 0.794924124
56  0.9957566685 0.78814053 0.238045684 0.769171735
57  0.3735068459 0.96358473 0.416595942 0.542958894
58  0.1958392843 0.44530268 0.377689107 0.710637979
59  0.2050307663 0.13226823 0.283356014 0.489012776
60  0.5653470247 0.90968078 0.545860195 0.047317949
61  0.4411608620 0.52077171 0.340286108 0.539908458
62  0.8883595073 0.38661564 0.095479671 0.317170956
63  0.9695977877 0.02958660 0.669279074 0.186123253
64  0.7528303906 0.84373976 0.834926706 0.496178930
65  0.1898490355 0.91013105 0.108255439 0.275015103
66  0.8559849195 0.57183803 0.329520850 0.749414672
67  0.8342585610 0.25799626 0.940779396 0.396223140
68  0.1402714337 0.24153215 0.487534100 0.893121778
69  0.7695200410 0.03579044 0.265213716 0.637468361
70  0.3049042285 0.92937437 0.817223059 0.195138498
71  0.9587073808 0.43570272 0.448628795 0.414701769
72  0.6809780616 0.76330262 0.608597009 0.588484796
73  0.6634705392 0.70253452 0.460586531 0.001914399
74  0.9831197091 0.73754260 0.470096959 0.400526261
75  0.5962137399 0.54718964 0.924977527 0.628370103
76  0.7901253907 0.95287338 0.792264981 0.253371729
77  0.4069840227 0.17088456 0.987133971 0.172421443
78  0.4869695256 0.48123071 0.022682303 0.358691509
79  0.0238862939 0.75930209 0.640152474 0.328513444
80  0.4193843028 0.40140038 0.499059015 0.297124414
81  0.7186402908 0.47208411 0.939409645 0.053872322
82  0.9377171381 0.99365998 0.551620561 0.697563058
83  0.3551358127 0.58061306 0.957987378 0.911977527
84  0.2931575403 0.23819608 0.137893421 0.015773451
85  0.8173699420 0.88571657 0.307284219 0.476633496
86  0.8450885118 0.68749444 0.969398063 0.839436935
87  0.0008571625 0.64166326 0.613628763 0.508953540
88  0.9194555717 0.11732215 0.298474076 0.687320010
89  0.9794818718 0.59221141 0.598295686 0.152675049
90  0.6567972411 0.04235433 0.122828104 0.755524721
91  0.6473035464 0.94392775 0.184556761 0.144955305
92  0.0691607533 0.32854935 0.773742367 0.777017995
93  0.8022726955 0.69533146 0.241972263 0.704568557
94  0.8605992107 0.93673051 0.826482441 0.123054850
95  0.0849028788 0.80919335 0.222575109 0.884711192
96  0.4926968629 0.28996365 0.363546839 0.840877710
97  0.7705400578 0.22245907 0.589003045 0.092889175
98  0.0986738922 0.46555039 0.216822631 0.570682999
99  0.0326839036 0.15864176 0.161682138 0.523639663
100 0.1581731710 0.26953439 0.206284252 0.389085505

$design.phys
             X1          X2        X3           X4
1   -0.81161662  0.01185434 133.32959   0.97576810
2   -0.85810610 -0.58581563 110.36876  -0.44745817
3   -0.31557971  0.31507312  39.57775  -3.40384193
4    0.43709689 -2.67714545  85.01955   1.47775776
5    1.89217582  0.09101337 124.49815   0.34144402
6   -2.46695011 -0.33348656  63.00800   5.39750562
7    0.61809093 -0.50501593 132.72125   1.39421362
8    2.58127363 -1.29680712  25.73644  -0.17024747
9   -2.27824415 -0.83651158  94.98900  -0.88468088
10  -2.94229018  2.17208965 119.29562   0.04793609
11   3.15507513  0.02806538 149.30205  -0.12936629
12   0.16521981  0.34148662  55.52160  -2.11962336
13   2.53136793 -1.34353173 111.75782   0.18047607
14   0.92293677 -1.24601995  35.56935  -2.29099090
15  -0.94056390 -1.45888056 129.94665  -0.59661422
16   0.01863126 -1.06051532 100.98582  -1.68093702
17  -0.16737393  0.97371849  42.78861   0.44268941
18   1.28564787 -2.25942485  60.52841  -0.95380459
19   0.13108451  1.12308536 130.97888   2.45614941
20  -0.52841107 -0.39803426  24.14313   1.96081068
21   1.01790276 -0.30917694 114.14857  -0.76593398
22  -1.53102831  0.94961412  71.99335   0.28555184
23  -1.85776247 -0.98886607 136.47354   0.16017266
24   1.31951737 -0.25426657  30.98463   0.29987663
25  -0.60395210 -0.00779563 137.28421  -0.49284018
26  -1.28173472  0.39789560  20.68913  -1.03294330
27  -0.92253251 -0.37748459  72.54871  -0.66947703
28  -1.31957723 -0.21195345  30.06136   1.06921499
29  -3.41819428 -1.15767125  74.79748  -0.39948940
30  -1.21060578  1.13080584 122.56522  -4.11840874
31  -1.42766347  0.16148982 105.61001   3.10293624
32   2.86301958 -0.41523355  69.60806   1.65365464
33   2.32305889 -1.59378621 113.30688   1.13552359
34  -0.35966402  0.25693570 115.96054  -2.41149930
35   0.35634524 -0.85160540 108.79405   0.47383335
36  -0.11592270 -0.53158604  22.36388  -0.99307343
37   0.70166470 -0.10639666  26.89266  -0.37960335
38  -4.11075662  0.60679007  38.49670  -1.48596350
39  -1.36430759 -0.49120792 134.59076   2.25879663
40  -0.69336628 -0.89578066 108.11794   4.33599829
41   1.57081237 -1.48487528  44.75996  -0.22603659
42   0.25840477 -0.77595206  86.99045   0.48317070
43  -1.13510982  0.76748433 117.22077   3.58184017
44  -1.92608094  0.41404474  78.85081   0.73648132
45  -0.20152551  0.13637706  28.37696   0.52654129
46   0.20531656  0.64703780  87.95012   0.71986627
47   1.06401006  0.57610963  93.47460  10.87177779
48   1.19962330  1.04050013  52.63549   1.23504728
49  -1.54478499  0.81517949 138.70312  -0.08627796
50   0.06010712  0.88931012  66.46405   2.86765722
51  -3.18313404  0.45432373  76.74261  -0.18679224
52   0.59756884  0.30381175 102.78665  -1.81238087
53   0.54521497  1.89489765  89.74913  -1.28839600
54  -2.23896679 -0.19779146 147.38927  -0.83748541
55  -2.37200416  1.27016727 118.61287   1.03301153
56   5.26413796  0.79998595  50.94594   0.90341708
57  -0.64515908  1.79389112  74.15747   0.12195707
58  -1.71315448 -0.13753825  69.09958   0.65691126
59  -1.64757070 -1.11573297  56.83628  -0.03108407
60   0.32908028  1.33879188  90.96183  -3.01523611
61  -0.29605333  0.05209050  64.23719   0.11323945
62   2.43569997 -0.28815085  32.41236  -0.55559392
63   3.74982991 -1.88690433 107.00628  -1.14049794
64   1.36684718  1.00994744 128.54047  -0.01080793
65  -1.75690549  1.34156248  34.07321  -0.71256684
66   2.12490566  0.18105559  62.83771   0.81395066
67   1.94226268 -0.64953517 142.30132  -0.30005949
68  -2.15820127 -0.70138257  83.37943   1.79945981
69   1.47453426 -1.80177458  54.47778   0.40440403
70  -1.02069378  1.47114742 126.23900  -1.08789136
71   3.47175792 -0.16187353  78.32174  -0.24484908
72   0.94087108  0.71696651  99.11761   0.25428637
73   0.84390710  0.53170410  79.87625 -16.11457379
74   4.24583939  0.63578770  81.11260  -0.28709317
75   0.48711765  0.11856410 140.24708   0.37567804
76   1.61371281  1.67337629 122.99445  -0.80191172
77  -0.47062023 -0.95067554 148.32742  -1.22639455
78  -0.06533673 -0.04706501  22.94870  -0.41666710
79  -3.95877157  0.70405935 103.21982  -0.51635673
80  -0.40693766 -0.24972404  84.87767  -0.62782179
81   1.15761397 -0.07003197 142.12325  -2.79457934
82   3.07177704  2.49263115  91.71067   0.60829127
83  -0.74298262  0.20346209 144.53836   2.05636249
84  -1.08836736 -0.71211729  37.92614  -5.49607560
85   1.81077507  1.20405879  59.94695  -0.06616274
86   2.03118710  0.48876070 146.02175   1.30754678
87  -6.27144102  0.36290817  99.77174   0.02532850
88   2.80283771 -1.18848015  58.80163   0.57143868
89   4.08632698  0.23323727  97.77844  -1.36565799
90   0.80747566 -1.72399550  35.96765   0.84082595
91   0.75610146  1.58862757  43.99238  -1.42622012
92  -2.96414123 -0.44392239 120.58651   0.94117966
93   1.69953411  0.51101997  51.45639   0.63410896
94   2.16603084  1.52789348 127.44272  -1.62277226
95  -2.74565643  0.87492761  48.93476   1.70355235
96  -0.03661454 -0.55349090  67.26109   1.31789761
97   1.48125317 -0.76391459  96.57040  -1.98342107
98  -2.57828941 -0.08645996  48.18694   0.20194981
99  -3.68546869 -1.00005578  41.01868   0.06693792
100 -2.00398862 -0.61422177  46.81695  -0.32172926

>   
> # **********************
> # Sensitivity analysis
> # **********************
>   
> ##Simulate the input sample
> M=10000
> Xmass <- data.frame(X1 = rnorm(M, 100, 5e-5),
+                     X2 = rnorm(M, 0.001234, 2e-5),
+                     X3 = runif(M, 1100, 1300),
+                     X4 = runif(M,7000000,9000000),
+                     X5 = runif(M,7950000,8050000))#Data-frame
> 
> #Define the measurement model (GUM-S1, 9.3)
> calibMass <-function(x){
+   return(((x[,1]+x[,2])*(1+(x[,3]-1200)*(1/x[,4]-1/x[,5]))-100)*1e3)
+ }
> 
> #####   Use SRRC with a model function    #####
> #Apply sensitivityMet function to evaluate the associated SRRC indices
> S_SRRC=sensitivityMet(model=calibMass,x=Xmass, nboot=100, method="SRRC", conf=0.95)
> ##Print the results
> #First order indices
> S_SRRC$S1
       original          bias  std. error   min. c.i.  max. c.i.
X1  0.672771323 -6.264778e-04 0.006057061  0.66172604 0.68636400
X2  0.243597457  9.371200e-04 0.007259588  0.22685519 0.25580341
X3  0.042463891  1.000675e-03 0.008562264  0.02445177 0.05950622
X4 -0.001611794 -7.366560e-04 0.009144869 -0.02075214 0.01821433
X5  0.002474392  9.785096e-05 0.006880062 -0.01084301 0.01770016
> 
> #####   Use Sobol with a computational code   #####
> #Creation of the design for the computation of Sobol sensitivity indices
> S_Sobol=sensitivityMet(model=NULL,x=Xmass,y=NULL, nboot=100, method="Sobol", conf=0.95)
> 
> #Obtain the design of experiment to submit to the code
> XDesign=S_Sobol$SI$X
> 
> #Run the computational code with XDesign as a sample of the input quantities
> #We use calibMass function (see GUM-S1) as an example
> YDesign=calibMass(XDesign)
> 
> #Run the Sobol indices calculations with the outputs of the code
> S_Sobol$SI=tell(x=S_Sobol$SI,y=YDesign)
> 
> ##Print the results
> #First order indices
> S_Sobol$SI$S
       original          bias std. error   min. c.i.  max. c.i.
X1  0.504425438  0.0133571390 0.21732657  0.01209324 0.88269433
X2  0.048509465 -0.0070097248 0.10085058 -0.15332387 0.23927162
X3 -0.209725104 -0.0150660979 0.23499151 -0.67993808 0.25966630
X4 -0.191204957 -0.0197641071 0.20791980 -0.58281484 0.22847324
X5 -0.009075858  0.0002783838 0.01260027 -0.03184695 0.02054133
> #Total order indices
> S_Sobol$SI$T 
      original          bias std. error   min. c.i. max. c.i.
X1 0.396112013 -0.0128938716 0.21770239  0.01083381 0.9130438
X2 0.087877461  0.0074810959 0.10042749 -0.11292719 0.2846431
X3 0.632148799  0.0149773352 0.23687739  0.14741296 1.0936121
X4 0.661992570  0.0162185697 0.20874822  0.24347559 1.0524517
X5 0.008653821 -0.0003186925 0.01244494 -0.02019190 0.0305413
>   
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>