<!-- Generated by pkgdown: do not edit by hand --> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Subsetting method for mmkin objects — [.mmkin • mkin</title> <!-- jquery --> <script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq" crossorigin="anonymous"></script> <!-- Bootstrap --> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> <!-- Font Awesome icons --> <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous"> <!-- clipboard.js --> <script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.7.1/clipboard.min.js" integrity="sha384-cV+rhyOuRHc9Ub/91rihWcGmMmCXDeksTtCihMupQHSsi8GIIRDG0ThDc3HGQFJ3" crossorigin="anonymous"></script> <!-- sticky kit --> <script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script> <!-- pkgdown --> <link href="../pkgdown.css" rel="stylesheet"> <script src="../pkgdown.js"></script> <meta property="og:title" content="Subsetting method for mmkin objects — [.mmkin" /> <meta property="og:description" content="Subsetting method for mmkin objects." /> <meta name="twitter:card" content="summary" /> <!-- mathjax --> <script src='https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> <div class="container template-reference-topic"> <header> <div class="navbar navbar-default navbar-fixed-top" role="navigation"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">mkin</a> <span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="Released package">0.9.47.2</span> </span> </div> <div id="navbar" class="navbar-collapse collapse"> <ul class="nav navbar-nav"> <li> <a href="../reference/index.html">Functions and data</a> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"> Articles <span class="caret"></span> </a> <ul class="dropdown-menu" role="menu"> <li> <a href="../articles/mkin.html">Introduction to mkin</a> </li> <li> <a href="../articles/FOCUS_D.html">Example evaluation of FOCUS Example Dataset D</a> </li> <li> <a href="../articles/FOCUS_L.html">Example evaluation of FOCUS Laboratory Data L1 to L3</a> </li> <li> <a href="../articles/FOCUS_Z.html">Example evaluation of FOCUS Example Dataset Z</a> </li> <li> <a href="../articles/compiled_models.html">Performance benefit by using compiled model definitions in mkin</a> </li> <li> <a href="../articles/twa.html">Calculation of time weighted average concentrations with mkin</a> </li> </ul> </li> <li> <a href="../news/index.html">News</a> </li> </ul> <ul class="nav navbar-nav navbar-right"> </ul> </div><!--/.nav-collapse --> </div><!--/.container --> </div><!--/.navbar --> </header> <div class="row"> <div class="col-md-9 contents"> <div class="page-header"> <h1>Subsetting method for mmkin objects</h1> <div class="hidden name"><code>Extract.mmkin.Rd</code></div> </div> <div class="ref-description"> <p>Subsetting method for mmkin objects.</p> </div> <pre class="usage"># S3 method for mmkin [(x, i, j, ..., drop = FALSE)</pre> <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2> <table class="ref-arguments"> <colgroup><col class="name" /><col class="desc" /></colgroup> <tr> <th>x</th> <td><p>An <code><a href='mmkin.html'>mmkin</a> object</code></p></td> </tr> <tr> <th>i</th> <td><p>Row index selecting the fits for specific models</p></td> </tr> <tr> <th>j</th> <td><p>Column index selecting the fits to specific datasets</p></td> </tr> <tr> <th>...</th> <td><p>Not used, only there to satisfy the generic method definition</p></td> </tr> <tr> <th>drop</th> <td><p>If FALSE, the method always returns an mmkin object, otherwise either a list of mkinfit objects or a single mkinfit object.</p></td> </tr> </table> <h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2> <p>An object of class <code><a href='mmkin.html'>mmkin</a></code>.</p> <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> <pre class="examples"><div class='input'> <span class='co'># Only use one core, to pass R CMD check --as-cran</span> <span class='no'>fits</span> <span class='kw'><-</span> <span class='fu'><a href='mmkin.html'>mmkin</a></span>(<span class='fu'>c</span>(<span class='st'>"SFO"</span>, <span class='st'>"FOMC"</span>), <span class='fu'>list</span>(<span class='kw'>B</span> <span class='kw'>=</span> <span class='no'>FOCUS_2006_B</span>, <span class='kw'>C</span> <span class='kw'>=</span> <span class='no'>FOCUS_2006_C</span>), <span class='kw'>cores</span> <span class='kw'>=</span> <span class='fl'>1</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>) <span class='no'>fits</span>[<span class='st'>"FOMC"</span>, ]</div><div class='output co'>#> dataset #> model B C #> FOMC List,45 List,45 #> attr(,"class") #> [1] "mmkin"</div><div class='input'> <span class='no'>fits</span>[, <span class='st'>"B"</span>]</div><div class='output co'>#> dataset #> model B #> SFO List,45 #> FOMC List,45 #> attr(,"class") #> [1] "mmkin"</div><div class='input'> <span class='no'>fits</span>[<span class='st'>"SFO"</span>, <span class='st'>"B"</span>]</div><div class='output co'>#> dataset #> model B #> SFO List,45 #> attr(,"class") #> [1] "mmkin"</div><div class='input'> <span class='fu'>head</span>( <span class='co'># This extracts an mkinfit object with lots of components</span> <span class='no'>fits</span><span class='kw'>[[</span><span class='st'>"FOMC"</span>, <span class='st'>"B"</span>]] )</div><div class='output co'>#> $par #> parent_0 log_alpha log_beta #> 99.666193 2.549849 5.050586 #> #> $ssr #> [1] 28.58291 #> #> $convergence #> [1] 0 #> #> $iterations #> [1] 21 #> #> $evaluations #> function gradient #> 25 78 #> #> $counts #> [1] "relative convergence (4)" #> </div><div class='input'> <span class='fu'>head</span>( <span class='co'># The same can be achieved by</span> <span class='no'>fits</span>[<span class='st'>"SFO"</span>, <span class='st'>"B"</span>, <span class='kw'>drop</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>] )</div><div class='output co'>#> [[1]] #> $par #> parent_0 log_k_parent_sink #> 99.174072 -2.549028 #> #> $ssr #> [1] 30.65564 #> #> $convergence #> [1] 0 #> #> $iterations #> [1] 5 #> #> $evaluations #> function gradient #> 8 15 #> #> $counts #> [1] "relative convergence (4)" #> #> $hessian #> parent_0 log_k_parent_sink #> parent_0 4.163631 -94.09343 #> log_k_parent_sink -94.093431 6311.34610 #> #> $residuals #> parent parent parent parent parent parent #> 0.55407218 -2.98452128 4.20445742 -1.68599939 -0.58185357 -0.72033730 #> parent parent #> -0.24260405 -0.07020339 #> #> $ms #> [1] 3.831956 #> #> $var_ms #> parent #> 3.831956 #> #> $var_ms_unscaled #> parent #> 3.831956 #> #> $var_ms_unweighted #> parent #> 3.831956 #> #> $rank #> [1] 2 #> #> $df.residual #> [1] 6 #> #> $solution_type #> [1] "analytical" #> #> $transform_rates #> [1] TRUE #> #> $transform_fractions #> [1] TRUE #> #> $method.modFit #> [1] "Port" #> #> $maxit.modFit #> [1] "auto" #> #> $calls #> [1] 29 #> #> $time #> User System verstrichen #> 0.171 0.001 0.171 #> #> $mkinmod #> <mkinmod> model generated with #> Use of formation fractions $use_of_ff: min #> Specification $spec: #> $parent #> $type: SFO; $sink: TRUE #> Coefficient matrix $coefmat available #> Differential equations: #> d_parent/dt = - k_parent_sink * parent #> #> $observed #> name time value #> 1 parent 0 98.62 #> 2 parent 3 81.43 #> 3 parent 7 53.18 #> 4 parent 14 34.89 #> 5 parent 30 10.09 #> 6 parent 62 1.50 #> 7 parent 90 0.33 #> 8 parent 118 0.08 #> #> $obs_vars #> [1] "parent" #> #> $predicted #> name time value #> 1 parent 0.000000 99.17407218 #> 2 parent 1.191919 90.35253561 #> 3 parent 2.383838 82.31567498 #> 4 parent 3.000000 78.44547872 #> 5 parent 3.575758 74.99369333 #> 6 parent 4.767677 68.32300215 #> 7 parent 5.959596 62.24566915 #> 8 parent 7.000000 57.38445742 #> 9 parent 7.151515 56.70891509 #> 10 parent 8.343434 51.66465547 #> 11 parent 9.535354 47.06908288 #> 12 parent 10.727273 42.88228661 #> 13 parent 11.919192 39.06790599 #> 14 parent 13.111111 35.59281463 #> 15 parent 14.000000 33.20400061 #> 16 parent 14.303030 32.42683275 #> 17 parent 15.494949 29.54246504 #> 18 parent 16.686869 26.91466193 #> 19 parent 17.878788 24.52060198 #> 20 parent 19.070707 22.33949373 #> 21 parent 20.262626 20.35239512 #> 22 parent 21.454545 18.54204899 #> 23 parent 22.646465 16.89273320 #> 24 parent 23.838384 15.39012410 #> 25 parent 25.030303 14.02117212 #> 26 parent 26.222222 12.77398846 #> 27 parent 27.414141 11.63774182 #> 28 parent 28.606061 10.60256435 #> 29 parent 29.797980 9.65946594 #> 30 parent 30.000000 9.50814643 #> 31 parent 30.989899 8.80025617 #> 32 parent 32.181818 8.01747313 #> 33 parent 33.373737 7.30431867 #> 34 parent 34.565657 6.65459931 #> 35 parent 35.757576 6.06267251 #> 36 parent 36.949495 5.52339762 #> 37 parent 38.141414 5.03209124 #> 38 parent 39.333333 4.58448658 #> 39 parent 40.525253 4.17669637 #> 40 parent 41.717172 3.80517911 #> 41 parent 42.909091 3.46670832 #> 42 parent 44.101010 3.15834451 #> 43 parent 45.292929 2.87740968 #> 44 parent 46.484848 2.62146400 #> 45 parent 47.676768 2.38828471 #> 46 parent 48.868687 2.17584671 #> 47 parent 50.060606 1.98230508 #> 48 parent 51.252525 1.80597899 #> 49 parent 52.444444 1.64533711 #> 50 parent 53.636364 1.49898432 #> 51 parent 54.828283 1.36564963 #> 52 parent 56.020202 1.24417505 #> 53 parent 57.212121 1.13350565 #> 54 parent 58.404040 1.03268029 #> 55 parent 59.595960 0.94082335 #> 56 parent 60.787879 0.85713708 #> 57 parent 61.979798 0.78089471 #> 58 parent 62.000000 0.77966270 #> 59 parent 63.171717 0.71143411 #> 60 parent 64.363636 0.64815202 #> 61 parent 65.555556 0.59049888 #> 62 parent 66.747475 0.53797399 #> 63 parent 67.939394 0.49012119 #> 64 parent 69.131313 0.44652489 #> 65 parent 70.323232 0.40680649 #> 66 parent 71.515152 0.37062104 #> 67 parent 72.707071 0.33765429 #> 68 parent 73.898990 0.30761993 #> 69 parent 75.090909 0.28025713 #> 70 parent 76.282828 0.25532825 #> 71 parent 77.474747 0.23261679 #> 72 parent 78.666667 0.21192552 #> 73 parent 79.858586 0.19307474 #> 74 parent 81.050505 0.17590074 #> 75 parent 82.242424 0.16025436 #> 76 parent 83.434343 0.14599973 #> 77 parent 84.626263 0.13301305 #> 78 parent 85.818182 0.12118154 #> 79 parent 87.010101 0.11040244 #> 80 parent 88.202020 0.10058214 #> 81 parent 89.393939 0.09163535 #> 82 parent 90.000000 0.08739595 #> 83 parent 90.585859 0.08348439 #> 84 parent 91.777778 0.07605845 #> 85 parent 92.969697 0.06929305 #> 86 parent 94.161616 0.06312943 #> 87 parent 95.353535 0.05751406 #> 88 parent 96.545455 0.05239819 #> 89 parent 97.737374 0.04773737 #> 90 parent 98.929293 0.04349113 #> 91 parent 100.121212 0.03962259 #> 92 parent 101.313131 0.03609816 #> 93 parent 102.505051 0.03288723 #> 94 parent 103.696970 0.02996191 #> 95 parent 104.888889 0.02729679 #> 96 parent 106.080808 0.02486874 #> 97 parent 107.272727 0.02265667 #> 98 parent 108.464646 0.02064136 #> 99 parent 109.656566 0.01880531 #> 100 parent 110.848485 0.01713257 #> 101 parent 112.040404 0.01560863 #> 102 parent 113.232323 0.01422024 #> 103 parent 114.424242 0.01295535 #> 104 parent 115.616162 0.01180297 #> 105 parent 116.808081 0.01075310 #> 106 parent 118.000000 0.00979661 #> #> $cost #> function (P) #> { #> assign("calls", calls + 1, inherits = TRUE) #> if (trace_parms) #> cat(P, "\n") #> if (length(state.ini.optim) > 0) { #> odeini <- c(P[1:length(state.ini.optim)], state.ini.fixed) #> names(odeini) <- c(state.ini.optim.boxnames, state.ini.fixed.boxnames) #> } #> else { #> odeini <- state.ini.fixed #> names(odeini) <- state.ini.fixed.boxnames #> } #> odeparms <- c(P[(length(state.ini.optim) + 1):length(P)], #> transparms.fixed) #> parms <- backtransform_odeparms(odeparms, mkinmod, transform_rates = transform_rates, #> transform_fractions = transform_fractions) #> out <- mkinpredict(mkinmod, parms, odeini, outtimes, solution_type = solution_type, #> use_compiled = use_compiled, method.ode = method.ode, #> atol = atol, rtol = rtol, ...) #> assign("out_predicted", out, inherits = TRUE) #> mC <- modCost(out, observed, y = "value", err = err, weight = weight, #> scaleVar = scaleVar) #> if (mC$model < cost.old) { #> if (!quiet) #> cat("Model cost at call ", calls, ": ", mC$model, #> "\n") #> if (plot) { #> outtimes_plot = seq(min(observed$time), max(observed$time), #> length.out = 100) #> out_plot <- mkinpredict(mkinmod, parms, odeini, outtimes_plot, #> solution_type = solution_type, use_compiled = use_compiled, #> method.ode = method.ode, atol = atol, rtol = rtol, #> ...) #> plot(0, type = "n", xlim = range(observed$time), #> ylim = c(0, max(observed$value, na.rm = TRUE)), #> xlab = "Time", ylab = "Observed") #> col_obs <- pch_obs <- 1:length(obs_vars) #> lty_obs <- rep(1, length(obs_vars)) #> names(col_obs) <- names(pch_obs) <- names(lty_obs) <- obs_vars #> for (obs_var in obs_vars) { #> points(subset(observed, name == obs_var, c(time, #> value)), pch = pch_obs[obs_var], col = col_obs[obs_var]) #> } #> matlines(out_plot$time, out_plot[-1], col = col_obs, #> lty = lty_obs) #> legend("topright", inset = c(0.05, 0.05), legend = obs_vars, #> col = col_obs, pch = pch_obs, lty = 1:length(pch_obs)) #> } #> assign("cost.old", mC$model, inherits = TRUE) #> } #> return(mC) #> } #> <bytecode: 0x55555bd7f970> #> <environment: 0x55555bc8fca8> #> #> $cost_notrans #> function (P) #> { #> if (length(state.ini.optim) > 0) { #> odeini <- c(P[1:length(state.ini.optim)], state.ini.fixed) #> names(odeini) <- c(state.ini.optim.boxnames, state.ini.fixed.boxnames) #> } #> else { #> odeini <- state.ini.fixed #> names(odeini) <- state.ini.fixed.boxnames #> } #> odeparms <- c(P[(length(state.ini.optim) + 1):length(P)], #> parms.fixed) #> out <- mkinpredict(mkinmod, odeparms, odeini, outtimes, solution_type = solution_type, #> use_compiled = use_compiled, method.ode = method.ode, #> atol = atol, rtol = rtol, ...) #> mC <- modCost(out, observed, y = "value", err = err, weight = weight, #> scaleVar = scaleVar) #> return(mC) #> } #> <bytecode: 0x55555ca84338> #> <environment: 0x55555bc8fca8> #> #> $hessian_notrans #> parent_0 k_parent_sink #> parent_0 4.163631 -1203.894 #> k_parent_sink -1203.893702 1033188.753 #> #> $start #> value type #> parent_0 98.62 state #> k_parent_sink 0.10 deparm #> #> $start_transformed #> value lower upper #> parent_0 98.620000 -Inf Inf #> log_k_parent_sink -2.302585 -Inf Inf #> #> $fixed #> [1] value type #> <0 Zeilen> (oder row.names mit Länge 0) #> #> $data #> time variable observed predicted residual #> 1 0 parent 98.62 99.17407218 -0.55407218 #> 2 3 parent 81.43 78.44547872 2.98452128 #> 3 7 parent 53.18 57.38445742 -4.20445742 #> 4 14 parent 34.89 33.20400061 1.68599939 #> 5 30 parent 10.09 9.50814643 0.58185357 #> 6 62 parent 1.50 0.77966270 0.72033730 #> 7 90 parent 0.33 0.08739595 0.24260405 #> 8 118 parent 0.08 0.00979661 0.07020339 #> #> $atol #> [1] 1e-08 #> #> $rtol #> [1] 1e-10 #> #> $weight.ini #> [1] "none" #> #> $tc.ini #> sigma_low rsd_high #> 0.50 0.07 #> #> $reweight.tol #> [1] 1e-08 #> #> $reweight.max.iter #> [1] 10 #> #> $bparms.optim #> parent_0 k_parent_sink #> 99.17407218 0.07815759 #> #> $bparms.fixed #> numeric(0) #> #> $bparms.ode #> k_parent_sink #> 0.07815759 #> #> $bparms.state #> parent #> 99.17407 #> #> $date #> [1] "Thu Sep 6 13:35:24 2018" #> #> $version #> [1] "0.9.47.2" #> #> $Rversion #> [1] "3.5.1" #> #> attr(,"class") #> [1] "mkinfit" "modFit" #> </div></pre> </div> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> <h2>Contents</h2> <ul class="nav nav-pills nav-stacked"> <li><a href="#arguments">Arguments</a></li> <li><a href="#value">Value</a></li> <li><a href="#examples">Examples</a></li> </ul> <h2>Author</h2> Johannes Ranke </div> </div> <footer> <div class="copyright"> <p>Developed by Johannes Ranke.</p> </div> <div class="pkgdown"> <p>Site built with <a href="http://pkgdown.r-lib.org/">pkgdown</a>.</p> </div> </footer> </div> </body> </html>