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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
|
<!-- Generated by pkgdown: do not edit by hand -->
<!DOCTYPE html>
<html lang="en">
<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>Fit nonlinear mixed models using nlmixr — nlmixr.mmkin • mkin</title>
<!-- jquery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha256-bZLfwXAP04zRMK2BjiO8iu9pf4FbLqX6zitd+tIvLhE=" crossorigin="anonymous" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script>
<!-- bootstrap-toc -->
<link rel="stylesheet" href="../bootstrap-toc.css">
<script src="../bootstrap-toc.js"></script>
<!-- Font Awesome icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous" />
<!-- clipboard.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script>
<!-- headroom.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script>
<!-- pkgdown -->
<link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script>
<meta property="og:title" content="Fit nonlinear mixed models using nlmixr — nlmixr.mmkin" />
<meta property="og:description" content="This function uses nlmixr::nlmixr() as a backend for fitting nonlinear mixed
effects models created from mmkin row objects using the Stochastic Approximation
Expectation Maximisation algorithm (SAEM) or First Order Conditional
Estimation with Interaction (FOCEI)." />
<meta name="robots" content="noindex">
<!-- mathjax -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></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 data-spy="scroll" data-target="#toc">
<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" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<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="version label label-info" data-toggle="tooltip" data-placement="bottom" title="In-development version">1.1.0</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/web_only/FOCUS_Z.html">Example evaluation of FOCUS Example Dataset Z</a>
</li>
<li>
<a href="../articles/web_only/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>
<li>
<a href="../articles/web_only/NAFTA_examples.html">Example evaluation of NAFTA SOP Attachment examples</a>
</li>
<li>
<a href="../articles/web_only/benchmarks.html">Some benchmark timings</a>
</li>
</ul>
</li>
<li>
<a href="../news/index.html">News</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/jranke/mkin/">
<span class="fab fa-github fa-lg"></span>
</a>
</li>
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
</header>
<div class="row">
<div class="col-md-9 contents">
<div class="page-header">
<h1>Fit nonlinear mixed models using nlmixr</h1>
<small class="dont-index">Source: <a href='https://github.com/jranke/mkin/blob/master/R/nlmixr.R'><code>R/nlmixr.R</code></a></small>
<div class="hidden name"><code>nlmixr.mmkin.Rd</code></div>
</div>
<div class="ref-description">
<p>This function uses <code><a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr::nlmixr()</a></code> as a backend for fitting nonlinear mixed
effects models created from <a href='mmkin.html'>mmkin</a> row objects using the Stochastic Approximation
Expectation Maximisation algorithm (SAEM) or First Order Conditional
Estimation with Interaction (FOCEI).</p>
</div>
<pre class="usage"><span class='co'># S3 method for mmkin</span>
<span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr</a></span><span class='op'>(</span>
<span class='va'>object</span>,
data <span class='op'>=</span> <span class='cn'>NULL</span>,
est <span class='op'>=</span> <span class='cn'>NULL</span>,
control <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span><span class='op'>(</span><span class='op'>)</span>,
table <span class='op'>=</span> <span class='fu'>tableControl</span><span class='op'>(</span><span class='op'>)</span>,
error_model <span class='op'>=</span> <span class='va'>object</span><span class='op'>[[</span><span class='fl'>1</span><span class='op'>]</span><span class='op'>]</span><span class='op'>$</span><span class='va'>err_mod</span>,
test_log_parms <span class='op'>=</span> <span class='cn'>TRUE</span>,
conf.level <span class='op'>=</span> <span class='fl'>0.6</span>,
degparms_start <span class='op'>=</span> <span class='st'>"auto"</span>,
eta_start <span class='op'>=</span> <span class='st'>"auto"</span>,
<span class='va'>...</span>,
save <span class='op'>=</span> <span class='cn'>NULL</span>,
envir <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/sys.parent.html'>parent.frame</a></span><span class='op'>(</span><span class='op'>)</span>
<span class='op'>)</span>
<span class='co'># S3 method for nlmixr.mmkin</span>
<span class='fu'><a href='https://rdrr.io/r/base/print.html'>print</a></span><span class='op'>(</span><span class='va'>x</span>, digits <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/Extremes.html'>max</a></span><span class='op'>(</span><span class='fl'>3</span>, <span class='fu'><a href='https://rdrr.io/r/base/options.html'>getOption</a></span><span class='op'>(</span><span class='st'>"digits"</span><span class='op'>)</span> <span class='op'>-</span> <span class='fl'>3</span><span class='op'>)</span>, <span class='va'>...</span><span class='op'>)</span>
<span class='fu'>nlmixr_model</span><span class='op'>(</span>
<span class='va'>object</span>,
est <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='st'>"saem"</span>, <span class='st'>"focei"</span><span class='op'>)</span>,
degparms_start <span class='op'>=</span> <span class='st'>"auto"</span>,
eta_start <span class='op'>=</span> <span class='st'>"auto"</span>,
test_log_parms <span class='op'>=</span> <span class='cn'>TRUE</span>,
conf.level <span class='op'>=</span> <span class='fl'>0.6</span>,
error_model <span class='op'>=</span> <span class='va'>object</span><span class='op'>[[</span><span class='fl'>1</span><span class='op'>]</span><span class='op'>]</span><span class='op'>$</span><span class='va'>err_mod</span>,
add_attributes <span class='op'>=</span> <span class='cn'>FALSE</span>
<span class='op'>)</span>
<span class='fu'>nlmixr_data</span><span class='op'>(</span><span class='va'>object</span>, <span class='va'>...</span><span class='op'>)</span></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>object</th>
<td><p>An <a href='mmkin.html'>mmkin</a> row object containing several fits of the same
<a href='mkinmod.html'>mkinmod</a> model to different datasets</p></td>
</tr>
<tr>
<th>data</th>
<td><p>Not used, as the data are extracted from the mmkin row object</p></td>
</tr>
<tr>
<th>est</th>
<td><p>Estimation method passed to <a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr::nlmixr</a></p></td>
</tr>
<tr>
<th>control</th>
<td><p>Passed to <a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr::nlmixr</a></p></td>
</tr>
<tr>
<th>table</th>
<td><p>Passed to <a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr::nlmixr</a></p></td>
</tr>
<tr>
<th>error_model</th>
<td><p>Optional argument to override the error model which is
being set based on the error model used in the mmkin row object.</p></td>
</tr>
<tr>
<th>test_log_parms</th>
<td><p>If TRUE, an attempt is made to use more robust starting
values for population parameters fitted as log parameters in mkin (like
rate constants) by only considering rate constants that pass the t-test
when calculating mean degradation parameters using <a href='mean_degparms.html'>mean_degparms</a>.</p></td>
</tr>
<tr>
<th>conf.level</th>
<td><p>Possibility to adjust the required confidence level
for parameter that are tested if requested by 'test_log_parms'.</p></td>
</tr>
<tr>
<th>degparms_start</th>
<td><p>Parameter values given as a named numeric vector will
be used to override the starting values obtained from the 'mmkin' object.</p></td>
</tr>
<tr>
<th>eta_start</th>
<td><p>Standard deviations on the transformed scale given as a
named numeric vector will be used to override the starting values obtained
from the 'mmkin' object.</p></td>
</tr>
<tr>
<th>...</th>
<td><p>Passed to nlmixr_model</p></td>
</tr>
<tr>
<th>save</th>
<td><p>Passed to <a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr::nlmixr</a></p></td>
</tr>
<tr>
<th>envir</th>
<td><p>Passed to <a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr::nlmixr</a></p></td>
</tr>
<tr>
<th>x</th>
<td><p>An nlmixr.mmkin object to print</p></td>
</tr>
<tr>
<th>digits</th>
<td><p>Number of digits to use for printing</p></td>
</tr>
<tr>
<th>add_attributes</th>
<td><p>Should the starting values used for degradation model
parameters and their distribution and for the error model parameters
be returned as attributes?</p></td>
</tr>
</table>
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
<p>An S3 object of class 'nlmixr.mmkin', containing the fitted
<a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr::nlmixr</a> object as a list component named 'nm'. The
object also inherits from 'mixed.mmkin'.</p>
<p>An function defining a model suitable for fitting with <a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr::nlmixr</a>.</p>
<p>An dataframe suitable for use with <a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr::nlmixr</a></p>
<h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>
<p>An mmkin row object is essentially a list of mkinfit objects that have been
obtained by fitting the same model to a list of datasets using <a href='mkinfit.html'>mkinfit</a>.</p>
<h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>
<div class='dont-index'><p><a href='summary.nlmixr.mmkin.html'>summary.nlmixr.mmkin</a> <a href='plot.mixed.mmkin.html'>plot.mixed.mmkin</a></p></div>
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><div class='input'><span class='co'># \dontrun{</span>
<span class='va'>ds</span> <span class='op'><-</span> <span class='fu'><a href='https://rdrr.io/r/base/lapply.html'>lapply</a></span><span class='op'>(</span><span class='va'>experimental_data_for_UBA_2019</span><span class='op'>[</span><span class='fl'>6</span><span class='op'>:</span><span class='fl'>10</span><span class='op'>]</span>,
<span class='kw'>function</span><span class='op'>(</span><span class='va'>x</span><span class='op'>)</span> <span class='fu'><a href='https://rdrr.io/r/base/subset.html'>subset</a></span><span class='op'>(</span><span class='va'>x</span><span class='op'>$</span><span class='va'>data</span><span class='op'>[</span><span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='st'>"name"</span>, <span class='st'>"time"</span>, <span class='st'>"value"</span><span class='op'>)</span><span class='op'>]</span><span class='op'>)</span><span class='op'>)</span>
<span class='fu'><a href='https://rdrr.io/r/base/names.html'>names</a></span><span class='op'>(</span><span class='va'>ds</span><span class='op'>)</span> <span class='op'><-</span> <span class='fu'><a href='https://rdrr.io/r/base/paste.html'>paste</a></span><span class='op'>(</span><span class='st'>"Dataset"</span>, <span class='fl'>6</span><span class='op'>:</span><span class='fl'>10</span><span class='op'>)</span>
<span class='va'>f_mmkin_parent</span> <span class='op'><-</span> <span class='fu'><a href='mmkin.html'>mmkin</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='st'>"SFO"</span>, <span class='st'>"FOMC"</span>, <span class='st'>"DFOP"</span>, <span class='st'>"HS"</span><span class='op'>)</span>, <span class='va'>ds</span>, quiet <span class='op'>=</span> <span class='cn'>TRUE</span>, cores <span class='op'>=</span> <span class='fl'>1</span><span class='op'>)</span>
<span class='va'>f_mmkin_parent_tc</span> <span class='op'><-</span> <span class='fu'><a href='mmkin.html'>mmkin</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='st'>"SFO"</span>, <span class='st'>"FOMC"</span>, <span class='st'>"DFOP"</span><span class='op'>)</span>, <span class='va'>ds</span>, error_model <span class='op'>=</span> <span class='st'>"tc"</span>,
cores <span class='op'>=</span> <span class='fl'>1</span>, quiet <span class='op'>=</span> <span class='cn'>TRUE</span><span class='op'>)</span>
<span class='kw'><a href='https://rdrr.io/r/base/library.html'>library</a></span><span class='op'>(</span><span class='va'><a href='https://github.com/nlmixrdevelopment/nlmixr'>nlmixr</a></span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'></span>
#> <span class='message'>Attaching package: ‘nlmixr’</span></div><div class='output co'>#> <span class='message'>The following object is masked from ‘package:mkin’:</span>
#> <span class='message'></span>
#> <span class='message'> saem</span></div><div class='input'><span class='va'>f_nlmixr_sfo_saem</span> <span class='op'><-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr</a></span><span class='op'>(</span><span class='va'>f_mmkin_parent</span><span class='op'>[</span><span class='st'>"SFO"</span>, <span class='op'>]</span>, est <span class='op'>=</span> <span class='st'>"saem"</span>,
control <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/saemControl.html'>saemControl</a></span><span class='op'>(</span>print <span class='op'>=</span> <span class='fl'>0</span><span class='op'>)</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> parameter labels from comments are typically ignored in non-interactive mode</span></div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> Need to run with the source intact to parse comments</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'>→ generate SAEM model</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>RxODE 1.1.1 using 8 threads (see ?getRxThreads)</span>
#> <span class='message'> no cache: create with `rxCreateCache()`</span></div><div class='output co'>#> <span class='message'>Calculating covariance matrix</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ compiling EBE model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>Calculating residuals/tables</span></div><div class='output co'>#> <span class='message'>done</span></div><div class='input'><span class='va'>f_nlmixr_sfo_focei</span> <span class='op'><-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr</a></span><span class='op'>(</span><span class='va'>f_mmkin_parent</span><span class='op'>[</span><span class='st'>"SFO"</span>, <span class='op'>]</span>, est <span class='op'>=</span> <span class='st'>"focei"</span>,
control <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/foceiControl.html'>foceiControl</a></span><span class='op'>(</span>print <span class='op'>=</span> <span class='fl'>0</span><span class='op'>)</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> parameter labels from comments are typically ignored in non-interactive mode</span></div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> Need to run with the source intact to parse comments</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ calculate jacobian</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate sensitivities</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(f)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(R²)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling inner model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling EBE model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ compiling events FD model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> calculating covariance matrix
#> done</div><div class='output co'>#> <span class='message'>Calculating residuals/tables</span></div><div class='output co'>#> <span class='message'>done</span></div><div class='output co'>#> <span class='warning'>Warning: initial ETAs were nudged; (can control by foceiControl(etaNudge=., etaNudge2=))</span></div><div class='output co'>#> <span class='warning'>Warning: last objective function was not at minimum, possible problems in optimization</span></div><div class='output co'>#> <span class='warning'>Warning: gradient problems with initial estimate and covariance; see $scaleInfo</span></div><div class='input'>
<span class='va'>f_nlmixr_fomc_saem</span> <span class='op'><-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr</a></span><span class='op'>(</span><span class='va'>f_mmkin_parent</span><span class='op'>[</span><span class='st'>"FOMC"</span>, <span class='op'>]</span>, est <span class='op'>=</span> <span class='st'>"saem"</span>,
control <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/saemControl.html'>saemControl</a></span><span class='op'>(</span>print <span class='op'>=</span> <span class='fl'>0</span><span class='op'>)</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> parameter labels from comments are typically ignored in non-interactive mode</span></div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> Need to run with the source intact to parse comments</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'>→ generate SAEM model</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>Calculating covariance matrix</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ compiling EBE model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>Calculating residuals/tables</span></div><div class='output co'>#> <span class='message'>done</span></div><div class='input'><span class='va'>f_nlmixr_fomc_focei</span> <span class='op'><-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr</a></span><span class='op'>(</span><span class='va'>f_mmkin_parent</span><span class='op'>[</span><span class='st'>"FOMC"</span>, <span class='op'>]</span>, est <span class='op'>=</span> <span class='st'>"focei"</span>,
control <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/foceiControl.html'>foceiControl</a></span><span class='op'>(</span>print <span class='op'>=</span> <span class='fl'>0</span><span class='op'>)</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> parameter labels from comments are typically ignored in non-interactive mode</span></div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> Need to run with the source intact to parse comments</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ calculate jacobian</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate sensitivities</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(f)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(R²)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling inner model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling EBE model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ compiling events FD model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> calculating covariance matrix
#> done</div><div class='output co'>#> <span class='message'>Calculating residuals/tables</span></div><div class='output co'>#> <span class='message'>done</span></div><div class='output co'>#> <span class='warning'>Warning: initial ETAs were nudged; (can control by foceiControl(etaNudge=., etaNudge2=))</span></div><div class='output co'>#> <span class='warning'>Warning: ETAs were reset to zero during optimization; (Can control by foceiControl(resetEtaP=.))</span></div><div class='output co'>#> <span class='warning'>Warning: last objective function was not at minimum, possible problems in optimization</span></div><div class='output co'>#> <span class='warning'>Warning: gradient problems with initial estimate and covariance; see $scaleInfo</span></div><div class='input'>
<span class='va'>f_nlmixr_dfop_saem</span> <span class='op'><-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr</a></span><span class='op'>(</span><span class='va'>f_mmkin_parent</span><span class='op'>[</span><span class='st'>"DFOP"</span>, <span class='op'>]</span>, est <span class='op'>=</span> <span class='st'>"saem"</span>,
control <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/saemControl.html'>saemControl</a></span><span class='op'>(</span>print <span class='op'>=</span> <span class='fl'>0</span><span class='op'>)</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> parameter labels from comments are typically ignored in non-interactive mode</span></div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> Need to run with the source intact to parse comments</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'>→ generate SAEM model</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>Calculating covariance matrix</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ compiling EBE model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>Calculating residuals/tables</span></div><div class='output co'>#> <span class='message'>done</span></div><div class='input'><span class='va'>f_nlmixr_dfop_focei</span> <span class='op'><-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr</a></span><span class='op'>(</span><span class='va'>f_mmkin_parent</span><span class='op'>[</span><span class='st'>"DFOP"</span>, <span class='op'>]</span>, est <span class='op'>=</span> <span class='st'>"focei"</span>,
control <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/foceiControl.html'>foceiControl</a></span><span class='op'>(</span>print <span class='op'>=</span> <span class='fl'>0</span><span class='op'>)</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> parameter labels from comments are typically ignored in non-interactive mode</span></div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> Need to run with the source intact to parse comments</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ calculate jacobian</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate sensitivities</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(f)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(R²)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling inner model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling EBE model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ compiling events FD model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> calculating covariance matrix
#> done</div><div class='output co'>#> <span class='message'>Calculating residuals/tables</span></div><div class='output co'>#> <span class='message'>done</span></div><div class='output co'>#> <span class='warning'>Warning: initial ETAs were nudged; (can control by foceiControl(etaNudge=., etaNudge2=))</span></div><div class='output co'>#> <span class='warning'>Warning: last objective function was not at minimum, possible problems in optimization</span></div><div class='output co'>#> <span class='warning'>Warning: gradient problems with initial estimate and covariance; see $scaleInfo</span></div><div class='input'>
<span class='va'>f_nlmixr_hs_saem</span> <span class='op'><-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr</a></span><span class='op'>(</span><span class='va'>f_mmkin_parent</span><span class='op'>[</span><span class='st'>"HS"</span>, <span class='op'>]</span>, est <span class='op'>=</span> <span class='st'>"saem"</span>,
control <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/saemControl.html'>saemControl</a></span><span class='op'>(</span>print <span class='op'>=</span> <span class='fl'>0</span><span class='op'>)</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> parameter labels from comments are typically ignored in non-interactive mode</span></div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> Need to run with the source intact to parse comments</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'>→ generate SAEM model</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>Calculating covariance matrix</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ compiling EBE model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>Calculating residuals/tables</span></div><div class='output co'>#> <span class='message'>done</span></div><div class='input'><span class='va'>f_nlmixr_hs_focei</span> <span class='op'><-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr</a></span><span class='op'>(</span><span class='va'>f_mmkin_parent</span><span class='op'>[</span><span class='st'>"HS"</span>, <span class='op'>]</span>, est <span class='op'>=</span> <span class='st'>"focei"</span>,
control <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/foceiControl.html'>foceiControl</a></span><span class='op'>(</span>print <span class='op'>=</span> <span class='fl'>0</span><span class='op'>)</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> parameter labels from comments are typically ignored in non-interactive mode</span></div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> Need to run with the source intact to parse comments</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ calculate jacobian</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate sensitivities</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(f)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(R²)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling inner model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling EBE model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ compiling events FD model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> calculating covariance matrix
#> done</div><div class='output co'>#> <span class='message'>Calculating residuals/tables</span></div><div class='output co'>#> <span class='message'>done</span></div><div class='output co'>#> <span class='warning'>Warning: initial ETAs were nudged; (can control by foceiControl(etaNudge=., etaNudge2=))</span></div><div class='output co'>#> <span class='warning'>Warning: last objective function was not at minimum, possible problems in optimization</span></div><div class='output co'>#> <span class='warning'>Warning: gradient problems with initial estimate and covariance; see $scaleInfo</span></div><div class='input'>
<span class='va'>f_nlmixr_fomc_saem_tc</span> <span class='op'><-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr</a></span><span class='op'>(</span><span class='va'>f_mmkin_parent_tc</span><span class='op'>[</span><span class='st'>"FOMC"</span>, <span class='op'>]</span>, est <span class='op'>=</span> <span class='st'>"saem"</span>,
control <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/saemControl.html'>saemControl</a></span><span class='op'>(</span>print <span class='op'>=</span> <span class='fl'>0</span><span class='op'>)</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> parameter labels from comments are typically ignored in non-interactive mode</span></div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> Need to run with the source intact to parse comments</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'>Calculating covariance matrix</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ compiling EBE model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>Calculating residuals/tables</span></div><div class='output co'>#> <span class='message'>done</span></div><div class='input'><span class='va'>f_nlmixr_fomc_focei_tc</span> <span class='op'><-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr</a></span><span class='op'>(</span><span class='va'>f_mmkin_parent_tc</span><span class='op'>[</span><span class='st'>"FOMC"</span>, <span class='op'>]</span>, est <span class='op'>=</span> <span class='st'>"focei"</span>,
control <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/foceiControl.html'>foceiControl</a></span><span class='op'>(</span>print <span class='op'>=</span> <span class='fl'>0</span><span class='op'>)</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> parameter labels from comments are typically ignored in non-interactive mode</span></div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> Need to run with the source intact to parse comments</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ calculate jacobian</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate sensitivities</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(f)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(R²)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling inner model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling EBE model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ compiling events FD model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> done</div><div class='output co'>#> <span class='message'>Calculating residuals/tables</span></div><div class='output co'>#> <span class='message'>done</span></div><div class='output co'>#> <span class='warning'>Warning: initial ETAs were nudged; (can control by foceiControl(etaNudge=., etaNudge2=))</span></div><div class='output co'>#> <span class='warning'>Warning: ETAs were reset to zero during optimization; (Can control by foceiControl(resetEtaP=.))</span></div><div class='output co'>#> <span class='warning'>Warning: last objective function was not at minimum, possible problems in optimization</span></div><div class='output co'>#> <span class='warning'>Warning: parameter estimate near boundary; covariance not calculated:</span>
#> <span class='warning'> "rsd_high" </span>
#> <span class='warning'> use 'getVarCov' to calculate anyway</span></div><div class='output co'>#> <span class='warning'>Warning: gradient problems with initial estimate; see $scaleInfo</span></div><div class='input'>
<span class='fu'><a href='https://rdrr.io/r/stats/AIC.html'>AIC</a></span><span class='op'>(</span>
<span class='va'>f_nlmixr_sfo_saem</span><span class='op'>$</span><span class='va'>nm</span>, <span class='va'>f_nlmixr_sfo_focei</span><span class='op'>$</span><span class='va'>nm</span>,
<span class='va'>f_nlmixr_fomc_saem</span><span class='op'>$</span><span class='va'>nm</span>, <span class='va'>f_nlmixr_fomc_focei</span><span class='op'>$</span><span class='va'>nm</span>,
<span class='va'>f_nlmixr_dfop_saem</span><span class='op'>$</span><span class='va'>nm</span>, <span class='va'>f_nlmixr_dfop_focei</span><span class='op'>$</span><span class='va'>nm</span>,
<span class='va'>f_nlmixr_hs_saem</span><span class='op'>$</span><span class='va'>nm</span>, <span class='va'>f_nlmixr_hs_focei</span><span class='op'>$</span><span class='va'>nm</span>,
<span class='va'>f_nlmixr_fomc_saem_tc</span><span class='op'>$</span><span class='va'>nm</span>, <span class='va'>f_nlmixr_fomc_focei_tc</span><span class='op'>$</span><span class='va'>nm</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'>Calculating -2LL by Gaussian quadrature (nnodes=3,nsd=1.6)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>Calculating -2LL by Gaussian quadrature (nnodes=3,nsd=1.6)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>Calculating -2LL by Gaussian quadrature (nnodes=3,nsd=1.6)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>Calculating -2LL by Gaussian quadrature (nnodes=3,nsd=1.6)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>Calculating -2LL by Gaussian quadrature (nnodes=3,nsd=1.6)</span></div><div class='output co'>#> </div><div class='output co'>#> df AIC
#> f_nlmixr_sfo_saem$nm 5 627.9197
#> f_nlmixr_sfo_focei$nm 5 625.0512
#> f_nlmixr_fomc_saem$nm 7 463.7245
#> f_nlmixr_fomc_focei$nm 7 468.0822
#> f_nlmixr_dfop_saem$nm 9 518.5794
#> f_nlmixr_dfop_focei$nm 9 537.6309
#> f_nlmixr_hs_saem$nm 9 535.9011
#> f_nlmixr_hs_focei$nm 9 544.7590
#> f_nlmixr_fomc_saem_tc$nm 8 463.5871
#> f_nlmixr_fomc_focei_tc$nm 8 470.0733</div><div class='input'>
<span class='fu'><a href='https://rdrr.io/r/stats/AIC.html'>AIC</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/pkg/nlme/man/nlme.html'>nlme</a></span><span class='op'>(</span><span class='va'>f_mmkin_parent</span><span class='op'>[</span><span class='st'>"FOMC"</span>, <span class='op'>]</span><span class='op'>)</span><span class='op'>)</span>
</div><div class='output co'>#> [1] 468.0781</div><div class='input'><span class='fu'><a href='https://rdrr.io/r/stats/AIC.html'>AIC</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/pkg/nlme/man/nlme.html'>nlme</a></span><span class='op'>(</span><span class='va'>f_mmkin_parent</span><span class='op'>[</span><span class='st'>"HS"</span>, <span class='op'>]</span><span class='op'>)</span><span class='op'>)</span>
</div><div class='output co'>#> [1] 535.609</div><div class='input'>
<span class='co'># The FOCEI fit of FOMC with constant variance or the tc error model is best</span>
<span class='fu'><a href='https://rdrr.io/r/graphics/plot.default.html'>plot</a></span><span class='op'>(</span><span class='va'>f_nlmixr_fomc_saem_tc</span><span class='op'>)</span>
</div><div class='img'><img src='nlmixr.mmkin-1.png' alt='' width='700' height='433' /></div><div class='input'>
<span class='va'>sfo_sfo</span> <span class='op'><-</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span><span class='op'>(</span>parent <span class='op'>=</span> <span class='fu'><a href='mkinmod.html'>mkinsub</a></span><span class='op'>(</span><span class='st'>"SFO"</span>, <span class='st'>"A1"</span><span class='op'>)</span>,
A1 <span class='op'>=</span> <span class='fu'><a href='mkinmod.html'>mkinsub</a></span><span class='op'>(</span><span class='st'>"SFO"</span><span class='op'>)</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'>Temporary DLL for differentials generated and loaded</span></div><div class='input'><span class='va'>fomc_sfo</span> <span class='op'><-</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span><span class='op'>(</span>parent <span class='op'>=</span> <span class='fu'><a href='mkinmod.html'>mkinsub</a></span><span class='op'>(</span><span class='st'>"FOMC"</span>, <span class='st'>"A1"</span><span class='op'>)</span>,
A1 <span class='op'>=</span> <span class='fu'><a href='mkinmod.html'>mkinsub</a></span><span class='op'>(</span><span class='st'>"SFO"</span><span class='op'>)</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'>Temporary DLL for differentials generated and loaded</span></div><div class='input'><span class='va'>dfop_sfo</span> <span class='op'><-</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span><span class='op'>(</span>parent <span class='op'>=</span> <span class='fu'><a href='mkinmod.html'>mkinsub</a></span><span class='op'>(</span><span class='st'>"DFOP"</span>, <span class='st'>"A1"</span><span class='op'>)</span>,
A1 <span class='op'>=</span> <span class='fu'><a href='mkinmod.html'>mkinsub</a></span><span class='op'>(</span><span class='st'>"SFO"</span><span class='op'>)</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'>Temporary DLL for differentials generated and loaded</span></div><div class='input'>
<span class='va'>f_mmkin_const</span> <span class='op'><-</span> <span class='fu'><a href='mmkin.html'>mmkin</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span><span class='op'>(</span>
<span class='st'>"SFO-SFO"</span> <span class='op'>=</span> <span class='va'>sfo_sfo</span>, <span class='st'>"FOMC-SFO"</span> <span class='op'>=</span> <span class='va'>fomc_sfo</span>, <span class='st'>"DFOP-SFO"</span> <span class='op'>=</span> <span class='va'>dfop_sfo</span><span class='op'>)</span>,
<span class='va'>ds</span>, quiet <span class='op'>=</span> <span class='cn'>TRUE</span>, error_model <span class='op'>=</span> <span class='st'>"const"</span><span class='op'>)</span>
<span class='va'>f_mmkin_obs</span> <span class='op'><-</span> <span class='fu'><a href='mmkin.html'>mmkin</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span><span class='op'>(</span>
<span class='st'>"SFO-SFO"</span> <span class='op'>=</span> <span class='va'>sfo_sfo</span>, <span class='st'>"FOMC-SFO"</span> <span class='op'>=</span> <span class='va'>fomc_sfo</span>, <span class='st'>"DFOP-SFO"</span> <span class='op'>=</span> <span class='va'>dfop_sfo</span><span class='op'>)</span>,
<span class='va'>ds</span>, quiet <span class='op'>=</span> <span class='cn'>TRUE</span>, error_model <span class='op'>=</span> <span class='st'>"obs"</span><span class='op'>)</span>
<span class='va'>f_mmkin_tc</span> <span class='op'><-</span> <span class='fu'><a href='mmkin.html'>mmkin</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span><span class='op'>(</span>
<span class='st'>"SFO-SFO"</span> <span class='op'>=</span> <span class='va'>sfo_sfo</span>, <span class='st'>"FOMC-SFO"</span> <span class='op'>=</span> <span class='va'>fomc_sfo</span>, <span class='st'>"DFOP-SFO"</span> <span class='op'>=</span> <span class='va'>dfop_sfo</span><span class='op'>)</span>,
<span class='va'>ds</span>, quiet <span class='op'>=</span> <span class='cn'>TRUE</span>, error_model <span class='op'>=</span> <span class='st'>"tc"</span><span class='op'>)</span>
<span class='co'># A single constant variance is currently only possible with est = 'focei' in nlmixr</span>
<span class='va'>f_nlmixr_sfo_sfo_focei_const</span> <span class='op'><-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr</a></span><span class='op'>(</span><span class='va'>f_mmkin_const</span><span class='op'>[</span><span class='st'>"SFO-SFO"</span>, <span class='op'>]</span>, est <span class='op'>=</span> <span class='st'>"focei"</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> parameter labels from comments are typically ignored in non-interactive mode</span></div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> Need to run with the source intact to parse comments</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ calculate jacobian</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate sensitivities</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(f)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(R²)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling inner model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling EBE model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ compiling events FD model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>Model:</span></div><div class='output co'>#> <span class='message'>cmt(parent);</span>
#> <span class='message'>cmt(A1);</span>
#> <span class='message'>rx_expr_6~ETA[1]+THETA[1];</span>
#> <span class='message'>parent(0)=rx_expr_6;</span>
#> <span class='message'>rx_expr_7~ETA[2]+THETA[2];</span>
#> <span class='message'>rx_expr_10~exp(rx_expr_7);</span>
#> <span class='message'>d/dt(parent)=-rx_expr_10*parent;</span>
#> <span class='message'>rx_expr_8~ETA[3]+THETA[3];</span>
#> <span class='message'>rx_expr_11~exp(rx_expr_8);</span>
#> <span class='message'>d/dt(A1)=-rx_expr_11*A1+rx_expr_10*parent*f_parent_to_A1;</span>
#> <span class='message'>rx_expr_0~CMT==2;</span>
#> <span class='message'>rx_expr_1~CMT==1;</span>
#> <span class='message'>rx_expr_2~1-(rx_expr_0);</span>
#> <span class='message'>rx_yj_~2*(rx_expr_2)*(rx_expr_1)+2*(rx_expr_0);</span>
#> <span class='message'>rx_expr_3~(rx_expr_0);</span>
#> <span class='message'>rx_expr_5~(rx_expr_2);</span>
#> <span class='message'>rx_expr_13~rx_expr_5*(rx_expr_1);</span>
#> <span class='message'>rx_lambda_~rx_expr_13+rx_expr_3;</span>
#> <span class='message'>rx_hi_~rx_expr_13+rx_expr_3;</span>
#> <span class='message'>rx_low_~0;</span>
#> <span class='message'>rx_expr_4~A1*(rx_expr_0);</span>
#> <span class='message'>rx_expr_9~parent*(rx_expr_2);</span>
#> <span class='message'>rx_expr_14~rx_expr_9*(rx_expr_1);</span>
#> <span class='message'>rx_pred_=(rx_expr_4+rx_expr_14)*(rx_expr_0)+(rx_expr_4+rx_expr_14)*(rx_expr_2)*(rx_expr_1);</span>
#> <span class='message'>rx_expr_12~Rx_pow_di(THETA[5],2);</span>
#> <span class='message'>rx_r_=(rx_expr_0)*rx_expr_12+(rx_expr_2)*(rx_expr_1)*rx_expr_12;</span>
#> <span class='message'>parent_0=THETA[1];</span>
#> <span class='message'>log_k_parent=THETA[2];</span>
#> <span class='message'>log_k_A1=THETA[3];</span>
#> <span class='message'>f_parent_qlogis=THETA[4];</span>
#> <span class='message'>sigma=THETA[5];</span>
#> <span class='message'>eta.parent_0=ETA[1];</span>
#> <span class='message'>eta.log_k_parent=ETA[2];</span>
#> <span class='message'>eta.log_k_A1=ETA[3];</span>
#> <span class='message'>eta.f_parent_qlogis=ETA[4];</span>
#> <span class='message'>parent_0_model=rx_expr_6;</span>
#> <span class='message'>k_parent=rx_expr_10;</span>
#> <span class='message'>k_A1=rx_expr_11;</span>
#> <span class='message'>f_parent=1/(1+exp(-(ETA[4]+THETA[4])));</span>
#> <span class='message'>tad=tad();</span>
#> <span class='message'>dosenum=dosenum();</span></div><div class='output co'>#> <span class='message'>Needed Covariates:</span></div><div class='output co'>#> <span class='message'>[1] "f_parent_to_A1" "CMT" </span></div><div class='output co'>#> <span class='error'>Error in (function (data, inits, PKpars, model = NULL, pred = NULL, err = NULL, lower = -Inf, upper = Inf, fixed = NULL, skipCov = NULL, control = foceiControl(), thetaNames = NULL, etaNames = NULL, etaMat = NULL, ..., env = NULL, keep = NULL, drop = NULL) { set.seed(control$seed) .pt <- proc.time() RxODE::.setWarnIdSort(FALSE) on.exit(RxODE::.setWarnIdSort(TRUE)) loadNamespace("n1qn1") if (!RxODE::rxIs(control, "foceiControl")) { control <- do.call(foceiControl, control) } if (is.null(env)) { .ret <- new.env(parent = emptyenv()) } else { .ret <- env } .ret$origData <- data .ret$etaNames <- etaNames .ret$thetaFixed <- fixed .ret$control <- control .ret$control$focei.mu.ref <- integer(0) if (is(model, "RxODE") || is(model, "character")) { .ret$ODEmodel <- TRUE if (class(pred) != "function") { stop("pred must be a function specifying the prediction variables in this model.") } } else { .ret$ODEmodel <- TRUE model <- RxODE::rxGetLin(PKpars) pred <- eval(parse(text = "function(){return(Central);}")) } .square <- function(x) x * x .ret$diagXformInv <- c(sqrt = ".square", log = "exp", identity = "identity")[control$diagXform] if (is.null(err)) { err <- eval(parse(text = paste0("function(){err", paste(inits$ERROR[[1]], collapse = ""), "}"))) } .covNames <- .parNames <- c() .ret$adjLik <- control$adjLik .mixed <- !is.null(inits$OMGA) && length(inits$OMGA) > 0 if (!exists("noLik", envir = .ret)) { .atol <- rep(control$atol, length(RxODE::rxModelVars(model)$state)) .rtol <- rep(control$rtol, length(RxODE::rxModelVars(model)$state)) .ssAtol <- rep(control$ssAtol, length(RxODE::rxModelVars(model)$state)) .ssRtol <- rep(control$ssRtol, length(RxODE::rxModelVars(model)$state)) .ret$model <- RxODE::rxSymPySetupPred(model, pred, PKpars, err, grad = (control$derivMethod == 2L), pred.minus.dv = TRUE, sum.prod = control$sumProd, theta.derivs = FALSE, optExpression = control$optExpression, interaction = (control$interaction == 1L), only.numeric = !.mixed, run.internal = TRUE, addProp = control$addProp) if (!is.null(.ret$model$inner)) { .atol <- c(.atol, rep(control$atolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.atol))) .rtol <- c(.rtol, rep(control$rtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.rtol))) .ret$control$rxControl$atol <- .atol .ret$control$rxControl$rtol <- .rtol .ssAtol <- c(.ssAtol, rep(control$ssAtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.ssAtol))) .ssRtol <- c(.ssRtol, rep(control$ssRtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.ssRtol))) .ret$control$rxControl$ssAtol <- .ssAtol .ret$control$rxControl$ssRtol <- .ssRtol } .covNames <- .parNames <- RxODE::rxParams(.ret$model$pred.only) .covNames <- .covNames[regexpr(rex::rex(start, or("THETA", "ETA"), "[", numbers, "]", end), .covNames) == -1] colnames(data) <- sapply(names(data), function(x) { if (any(x == .covNames)) { return(x) } else { return(toupper(x)) } }) .lhs <- c(names(RxODE::rxInits(.ret$model$pred.only)), RxODE::rxLhs(.ret$model$pred.only)) if (length(.lhs) > 0) { .covNames <- .covNames[regexpr(rex::rex(start, or(.lhs), end), .covNames) == -1] } if (length(.covNames) > 0) { if (!all(.covNames %in% names(data))) { message("Model:") RxODE::rxCat(.ret$model$pred.only) message("Needed Covariates:") nlmixrPrint(.covNames) stop("Not all the covariates are in the dataset.") } message("Needed Covariates:") print(.covNames) } .extraPars <- .ret$model$extra.pars } else { if (.ret$noLik) { .atol <- rep(control$atol, length(RxODE::rxModelVars(model)$state)) .rtol <- rep(control$rtol, length(RxODE::rxModelVars(model)$state)) .ret$model <- RxODE::rxSymPySetupPred(model, pred, PKpars, err, grad = FALSE, pred.minus.dv = TRUE, sum.prod = control$sumProd, theta.derivs = FALSE, optExpression = control$optExpression, run.internal = TRUE, only.numeric = TRUE, addProp = control$addProp) if (!is.null(.ret$model$inner)) { .atol <- c(.atol, rep(control$atolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.atol))) .rtol <- c(.rtol, rep(control$rtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.rtol))) .ret$control$rxControl$atol <- .atol .ret$control$rxControl$rtol <- .rtol } .covNames <- .parNames <- RxODE::rxParams(.ret$model$pred.only) .covNames <- .covNames[regexpr(rex::rex(start, or("THETA", "ETA"), "[", numbers, "]", end), .covNames) == -1] colnames(data) <- sapply(names(data), function(x) { if (any(x == .covNames)) { return(x) } else { return(toupper(x)) } }) .lhs <- c(names(RxODE::rxInits(.ret$model$pred.only)), RxODE::rxLhs(.ret$model$pred.only)) if (length(.lhs) > 0) { .covNames <- .covNames[regexpr(rex::rex(start, or(.lhs), end), .covNames) == -1] } if (length(.covNames) > 0) { if (!all(.covNames %in% names(data))) { message("Model:") RxODE::rxCat(.ret$model$pred.only) message("Needed Covariates:") nlmixrPrint(.covNames) stop("Not all the covariates are in the dataset.") } message("Needed Covariates:") print(.covNames) } .extraPars <- .ret$model$extra.pars } else { .extraPars <- NULL } } .ret$skipCov <- skipCov if (is.null(skipCov)) { if (is.null(fixed)) { .tmp <- rep(FALSE, length(inits$THTA)) } else { if (length(fixed) < length(inits$THTA)) { .tmp <- c(fixed, rep(FALSE, length(inits$THTA) - length(fixed))) } else { .tmp <- fixed[1:length(inits$THTA)] } } if (exists("uif", envir = .ret)) { .uifErr <- .ret$uif$ini$err[!is.na(.ret$uif$ini$ntheta)] .uifErr <- sapply(.uifErr, function(x) { if (is.na(x)) { return(FALSE) } return(!any(x == c("pow2", "tbs", "tbsYj"))) }) .tmp <- (.tmp | .uifErr) } .ret$skipCov <- c(.tmp, rep(TRUE, length(.extraPars))) .ret$control$focei.mu.ref <- .ret$uif$focei.mu.ref } if (is.null(.extraPars)) { .nms <- c(sprintf("THETA[%s]", seq_along(inits$THTA))) } else { .nms <- c(sprintf("THETA[%s]", seq_along(inits$THTA)), sprintf("ERR[%s]", seq_along(.extraPars))) } if (!is.null(thetaNames) && (length(inits$THTA) + length(.extraPars)) == length(thetaNames)) { .nms <- thetaNames } .ret$thetaNames <- .nms .thetaReset$thetaNames <- .nms if (length(lower) == 1) { lower <- rep(lower, length(inits$THTA)) } else if (length(lower) != length(inits$THTA)) { print(inits$THTA) print(lower) stop("Lower must be a single constant for all the THETA lower bounds, or match the dimension of THETA.") } if (length(upper) == 1) { upper <- rep(upper, length(inits$THTA)) } else if (length(lower) != length(inits$THTA)) { stop("Upper must be a single constant for all the THETA lower bounds, or match the dimension of THETA.") } if (!is.null(.extraPars)) { .ret$model$extra.pars <- eval(call(control$diagXform, .ret$model$extra.pars)) if (length(.ret$model$extra.pars) > 0) { inits$THTA <- c(inits$THTA, .ret$model$extra.pars) .lowerErr <- rep(control$atol[1] * 10, length(.ret$model$extra.pars)) .upperErr <- rep(Inf, length(.ret$model$extra.pars)) lower <- c(lower, .lowerErr) upper <- c(upper, .upperErr) } } if (is.null(data$ID)) stop("\"ID\" not found in data") if (is.null(data$DV)) stop("\"DV\" not found in data") if (is.null(data$EVID)) data$EVID <- 0 if (is.null(data$AMT)) data$AMT <- 0 for (.v in c("TIME", "AMT", "DV", .covNames)) { data[[.v]] <- as.double(data[[.v]]) } .ret$dataSav <- data .ds <- data[data$EVID != 0 & data$EVID != 2, c("ID", "TIME", "AMT", "EVID", .covNames)] .w <- which(tolower(names(data)) == "limit") .limitName <- NULL if (length(.w) == 1L) { .limitName <- names(data)[.w] } .censName <- NULL .w <- which(tolower(names(data)) == "cens") if (length(.w) == 1L) { .censName <- names(data[.w]) } data <- data[data$EVID == 0 | data$EVID == 2, c("ID", "TIME", "DV", "EVID", .covNames, .limitName, .censName)] .w <- which(!(names(.ret$dataSav) %in% c(.covNames, keep))) names(.ret$dataSav)[.w] <- tolower(names(.ret$dataSav[.w])) if (.mixed) { .lh <- .parseOM(inits$OMGA) .nlh <- sapply(.lh, length) .osplt <- rep(1:length(.lh), .nlh) .lini <- list(inits$THTA, unlist(.lh)) .nlini <- sapply(.lini, length) .nsplt <- rep(1:length(.lini), .nlini) .om0 <- .genOM(.lh) if (length(etaNames) == dim(.om0)[1]) { .ret$etaNames <- .ret$etaNames } else { .ret$etaNames <- sprintf("ETA[%d]", seq(1, dim(.om0)[1])) } .ret$rxInv <- RxODE::rxSymInvCholCreate(mat = .om0, diag.xform = control$diagXform) .ret$xType <- .ret$rxInv$xType .om0a <- .om0 .om0a <- .om0a/control$diagOmegaBoundLower .om0b <- .om0 .om0b <- .om0b * control$diagOmegaBoundUpper .om0a <- RxODE::rxSymInvCholCreate(mat = .om0a, diag.xform = control$diagXform) .om0b <- RxODE::rxSymInvCholCreate(mat = .om0b, diag.xform = control$diagXform) .omdf <- data.frame(a = .om0a$theta, m = .ret$rxInv$theta, b = .om0b$theta, diag = .om0a$theta.diag) .omdf$lower <- with(.omdf, ifelse(a > b, b, a)) .omdf$lower <- with(.omdf, ifelse(lower == m, -Inf, lower)) .omdf$lower <- with(.omdf, ifelse(!diag, -Inf, lower)) .omdf$upper <- with(.omdf, ifelse(a < b, b, a)) .omdf$upper <- with(.omdf, ifelse(upper == m, Inf, upper)) .omdf$upper <- with(.omdf, ifelse(!diag, Inf, upper)) .ret$control$nomega <- length(.omdf$lower) .ret$control$neta <- sum(.omdf$diag) .ret$control$ntheta <- length(lower) .ret$control$nfixed <- sum(fixed) lower <- c(lower, .omdf$lower) upper <- c(upper, .omdf$upper) } else { .ret$control$nomega <- 0 .ret$control$neta <- 0 .ret$xType <- -1 .ret$control$ntheta <- length(lower) .ret$control$nfixed <- sum(fixed) } .ret$lower <- lower .ret$upper <- upper .ret$thetaIni <- inits$THTA .scaleC <- double(length(lower)) if (is.null(control$scaleC)) { .scaleC <- rep(NA_real_, length(lower)) } else { .scaleC <- as.double(control$scaleC) if (length(lower) > length(.scaleC)) { .scaleC <- c(.scaleC, rep(NA_real_, length(lower) - length(.scaleC))) } else if (length(lower) < length(.scaleC)) { .scaleC <- .scaleC[seq(1, length(lower))] warning("scaleC control option has more options than estimated population parameters, please check.") } } .ret$scaleC <- .scaleC if (exists("uif", envir = .ret)) { .ini <- as.data.frame(.ret$uif$ini)[!is.na(.ret$uif$ini$err), c("est", "err", "ntheta")] for (.i in seq_along(.ini$err)) { if (is.na(.ret$scaleC[.ini$ntheta[.i]])) { if (any(.ini$err[.i] == c("boxCox", "yeoJohnson", "pow2", "tbs", "tbsYj"))) { .ret$scaleC[.ini$ntheta[.i]] <- 1 } else if (any(.ini$err[.i] == c("prop", "add", "norm", "dnorm", "logn", "dlogn", "lnorm", "dlnorm"))) { .ret$scaleC[.ini$ntheta[.i]] <- 0.5 * abs(.ini$est[.i]) } } } for (.i in .ini$model$extraProps$powTheta) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- 1 } .ini <- as.data.frame(.ret$uif$ini) for (.i in .ini$model$extraProps$factorial) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- abs(1/digamma(.ini$est[.i] + 1)) } for (.i in .ini$model$extraProps$gamma) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- abs(1/digamma(.ini$est[.i])) } for (.i in .ini$model$extraProps$log) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- log(abs(.ini$est[.i])) * abs(.ini$est[.i]) } for (.i in .ret$logitThetas) { .b <- .ret$logitThetasLow[.i] .c <- .ret$logitThetasHi[.i] .a <- .ini$est[.i] if (is.na(.ret$scaleC[.i])) { .ret$scaleC[.i] <- 1 * (-.b + .c) * exp(-.a)/((1 + exp(-.a))^2 * (.b + 1 * (-.b + .c)/(1 + exp(-.a)))) } } } names(.ret$thetaIni) <- sprintf("THETA[%d]", seq_along(.ret$thetaIni)) if (is.null(etaMat) & !is.null(control$etaMat)) { .ret$etaMat <- control$etaMat } else { .ret$etaMat <- etaMat } .ret$setupTime <- (proc.time() - .pt)["elapsed"] if (exists("uif", envir = .ret)) { .tmp <- .ret$uif$logThetasList .ret$logThetas <- .tmp[[1]] .ret$logThetasF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasList .ret$logitThetas <- .tmp[[1]] .ret$logitThetasF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasListLow .ret$logitThetasLow <- .tmp[[1]] .ret$logitThetasLowF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasListHi .ret$logitThetasHi <- .tmp[[1]] .ret$logitThetasHiF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasList .ret$probitThetas <- .tmp[[1]] .ret$probitThetasF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasListLow .ret$probitThetasLow <- .tmp[[1]] .ret$probitThetasLowF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasListHi .ret$probitThetasHi <- .tmp[[1]] .ret$probitThetasHiF <- .tmp[[2]] } else { .ret$logThetasF <- integer(0) .ret$logitThetasF <- integer(0) .ret$logitThetasHiF <- numeric(0) .ret$logitThetasLowF <- numeric(0) .ret$logitThetas <- integer(0) .ret$logitThetasHi <- numeric(0) .ret$logitThetasLow <- numeric(0) .ret$probitThetasF <- integer(0) .ret$probitThetasHiF <- numeric(0) .ret$probitThetasLowF <- numeric(0) .ret$probitThetas <- integer(0) .ret$probitThetasHi <- numeric(0) .ret$probitThetasLow <- numeric(0) } if (exists("noLik", envir = .ret)) { if (!.ret$noLik) { .ret$.params <- c(sprintf("THETA[%d]", seq_along(.ret$thetaIni)), sprintf("ETA[%d]", seq(1, dim(.om0)[1]))) .ret$.thetan <- length(.ret$thetaIni) .ret$nobs <- sum(data$EVID == 0) } } .ret$control$printTop <- TRUE .ret$control$nF <- 0 .est0 <- .ret$thetaIni if (!is.null(.ret$model$pred.nolhs)) { .ret$control$predNeq <- length(.ret$model$pred.nolhs$state) } else { .ret$control$predNeq <- 0L } .fitFun <- function(.ret) { this.env <- environment() assign("err", "theta reset", this.env) while (this.env$err == "theta reset") { assign("err", "", this.env) .ret0 <- tryCatch({ foceiFitCpp_(.ret) }, error = function(e) { if (regexpr("theta reset", e$message) != -1) { assign("zeroOuter", FALSE, this.env) assign("zeroGrad", FALSE, this.env) if (regexpr("theta reset0", e$message) != -1) { assign("zeroGrad", TRUE, this.env) } else if (regexpr("theta resetZ", e$message) != -1) { assign("zeroOuter", TRUE, this.env) } assign("err", "theta reset", this.env) } else { assign("err", e$message, this.env) } }) if (this.env$err == "theta reset") { .nm <- names(.ret$thetaIni) .ret$thetaIni <- setNames(.thetaReset$thetaIni + 0, .nm) .ret$rxInv$theta <- .thetaReset$omegaTheta .ret$control$printTop <- FALSE .ret$etaMat <- .thetaReset$etaMat .ret$control$etaMat <- .thetaReset$etaMat .ret$control$maxInnerIterations <- .thetaReset$maxInnerIterations .ret$control$nF <- .thetaReset$nF .ret$control$gillRetC <- .thetaReset$gillRetC .ret$control$gillRet <- .thetaReset$gillRet .ret$control$gillRet <- .thetaReset$gillRet .ret$control$gillDf <- .thetaReset$gillDf .ret$control$gillDf2 <- .thetaReset$gillDf2 .ret$control$gillErr <- .thetaReset$gillErr .ret$control$rEps <- .thetaReset$rEps .ret$control$aEps <- .thetaReset$aEps .ret$control$rEpsC <- .thetaReset$rEpsC .ret$control$aEpsC <- .thetaReset$aEpsC .ret$control$c1 <- .thetaReset$c1 .ret$control$c2 <- .thetaReset$c2 if (this.env$zeroOuter) { message("Posthoc reset") .ret$control$maxOuterIterations <- 0L } else if (this.env$zeroGrad) { message("Theta reset (zero gradient values); Switch to bobyqa") RxODE::rxReq("minqa") .ret$control$outerOptFun <- .bobyqa .ret$control$outerOpt <- -1L } else { message("Theta reset (ETA drift)") } } } if (this.env$err != "") { stop(this.env$err) } else { return(.ret0) } } .ret0 <- try(.fitFun(.ret)) .n <- 1 while (inherits(.ret0, "try-error") && control$maxOuterIterations != 0 && .n <= control$nRetries) { message(sprintf("Restart %s", .n)) .ret$control$nF <- 0 .estNew <- .est0 + 0.2 * .n * abs(.est0) * stats::runif(length(.est0)) - 0.1 * .n .estNew <- sapply(seq_along(.est0), function(.i) { if (.ret$thetaFixed[.i]) { return(.est0[.i]) } else if (.estNew[.i] < lower[.i]) { return(lower + (.Machine$double.eps)^(1/7)) } else if (.estNew[.i] > upper[.i]) { return(upper - (.Machine$double.eps)^(1/7)) } else { return(.estNew[.i]) } }) .ret$thetaIni <- .estNew .ret0 <- try(.fitFun(.ret)) .n <- .n + 1 } if (inherits(.ret0, "try-error")) stop("Could not fit data.") .ret <- .ret0 if (exists("parHistData", .ret)) { .tmp <- .ret$parHistData .tmp <- .tmp[.tmp$type == "Unscaled", names(.tmp) != "type"] .iter <- .tmp$iter .tmp <- .tmp[, names(.tmp) != "iter"] .ret$parHistStacked <- data.frame(stack(.tmp), iter = .iter) names(.ret$parHistStacked) <- c("val", "par", "iter") .ret$parHist <- data.frame(iter = .iter, .tmp) } if (.mixed) { .etas <- .ret$ranef .thetas <- .ret$fixef .pars <- .Call(`_nlmixr_nlmixrParameters`, .thetas, .etas) .ret$shrink <- .Call(`_nlmixr_calcShrinkOnly`, .ret$omega, .pars$eta.lst, length(.etas$ID)) .updateParFixed(.ret) } else { .updateParFixed(.ret) } if (!exists("table", .ret)) { .ret$table <- tableControl() } if (control$calcTables) { .ret <- addTable(.ret, updateObject = "no", keep = keep, drop = drop, table = .ret$table) } .ret})(data = dat, inits = .FoceiInits, PKpars = .pars, model = .mod, pred = function() { return(nlmixr_pred) }, err = uif$error, lower = uif$focei.lower, upper = uif$focei.upper, fixed = uif$focei.fixed, thetaNames = uif$focei.names, etaNames = uif$eta.names, control = control, env = env, keep = .keep, drop = .drop): Not all the covariates are in the dataset.</span></div><div class='output co'>#> <span class='message'>Timing stopped at: 5.549 0.41 5.959</span></div><div class='input'><span class='va'>f_nlmixr_fomc_sfo_focei_const</span> <span class='op'><-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr</a></span><span class='op'>(</span><span class='va'>f_mmkin_const</span><span class='op'>[</span><span class='st'>"FOMC-SFO"</span>, <span class='op'>]</span>, est <span class='op'>=</span> <span class='st'>"focei"</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> parameter labels from comments are typically ignored in non-interactive mode</span></div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> Need to run with the source intact to parse comments</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ calculate jacobian</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate sensitivities</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(f)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(R²)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling inner model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling EBE model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ compiling events FD model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>Model:</span></div><div class='output co'>#> <span class='message'>cmt(parent);</span>
#> <span class='message'>cmt(A1);</span>
#> <span class='message'>rx_expr_6~ETA[1]+THETA[1];</span>
#> <span class='message'>parent(0)=rx_expr_6;</span>
#> <span class='message'>rx_expr_7~ETA[4]+THETA[4];</span>
#> <span class='message'>rx_expr_8~ETA[5]+THETA[5];</span>
#> <span class='message'>rx_expr_13~exp(-(rx_expr_8));</span>
#> <span class='message'>rx_expr_15~t*rx_expr_13;</span>
#> <span class='message'>rx_expr_16~1+rx_expr_15;</span>
#> <span class='message'>rx_expr_18~rx_expr_7-(rx_expr_8);</span>
#> <span class='message'>rx_expr_20~exp(rx_expr_18);</span>
#> <span class='message'>d/dt(parent)=-rx_expr_20*parent/(rx_expr_16);</span>
#> <span class='message'>rx_expr_9~ETA[2]+THETA[2];</span>
#> <span class='message'>rx_expr_11~exp(rx_expr_9);</span>
#> <span class='message'>d/dt(A1)=-rx_expr_11*A1+rx_expr_20*parent*f_parent_to_A1/(rx_expr_16);</span>
#> <span class='message'>rx_expr_0~CMT==2;</span>
#> <span class='message'>rx_expr_1~CMT==1;</span>
#> <span class='message'>rx_expr_2~1-(rx_expr_0);</span>
#> <span class='message'>rx_yj_~2*(rx_expr_2)*(rx_expr_1)+2*(rx_expr_0);</span>
#> <span class='message'>rx_expr_3~(rx_expr_0);</span>
#> <span class='message'>rx_expr_5~(rx_expr_2);</span>
#> <span class='message'>rx_expr_14~rx_expr_5*(rx_expr_1);</span>
#> <span class='message'>rx_lambda_~rx_expr_14+rx_expr_3;</span>
#> <span class='message'>rx_hi_~rx_expr_14+rx_expr_3;</span>
#> <span class='message'>rx_low_~0;</span>
#> <span class='message'>rx_expr_4~A1*(rx_expr_0);</span>
#> <span class='message'>rx_expr_10~parent*(rx_expr_2);</span>
#> <span class='message'>rx_expr_17~rx_expr_10*(rx_expr_1);</span>
#> <span class='message'>rx_pred_=(rx_expr_4+rx_expr_17)*(rx_expr_0)+(rx_expr_4+rx_expr_17)*(rx_expr_2)*(rx_expr_1);</span>
#> <span class='message'>rx_expr_12~Rx_pow_di(THETA[6],2);</span>
#> <span class='message'>rx_r_=(rx_expr_0)*rx_expr_12+(rx_expr_2)*(rx_expr_1)*rx_expr_12;</span>
#> <span class='message'>parent_0=THETA[1];</span>
#> <span class='message'>log_k_A1=THETA[2];</span>
#> <span class='message'>f_parent_qlogis=THETA[3];</span>
#> <span class='message'>log_alpha=THETA[4];</span>
#> <span class='message'>log_beta=THETA[5];</span>
#> <span class='message'>sigma=THETA[6];</span>
#> <span class='message'>eta.parent_0=ETA[1];</span>
#> <span class='message'>eta.log_k_A1=ETA[2];</span>
#> <span class='message'>eta.f_parent_qlogis=ETA[3];</span>
#> <span class='message'>eta.log_alpha=ETA[4];</span>
#> <span class='message'>eta.log_beta=ETA[5];</span>
#> <span class='message'>parent_0_model=rx_expr_6;</span>
#> <span class='message'>k_A1=rx_expr_11;</span>
#> <span class='message'>alpha=exp(rx_expr_7);</span>
#> <span class='message'>beta=exp(rx_expr_8);</span>
#> <span class='message'>f_parent=1/(1+exp(-(ETA[3]+THETA[3])));</span>
#> <span class='message'>tad=tad();</span>
#> <span class='message'>dosenum=dosenum();</span></div><div class='output co'>#> <span class='message'>Needed Covariates:</span></div><div class='output co'>#> <span class='message'>[1] "f_parent_to_A1" "CMT" </span></div><div class='output co'>#> <span class='error'>Error in (function (data, inits, PKpars, model = NULL, pred = NULL, err = NULL, lower = -Inf, upper = Inf, fixed = NULL, skipCov = NULL, control = foceiControl(), thetaNames = NULL, etaNames = NULL, etaMat = NULL, ..., env = NULL, keep = NULL, drop = NULL) { set.seed(control$seed) .pt <- proc.time() RxODE::.setWarnIdSort(FALSE) on.exit(RxODE::.setWarnIdSort(TRUE)) loadNamespace("n1qn1") if (!RxODE::rxIs(control, "foceiControl")) { control <- do.call(foceiControl, control) } if (is.null(env)) { .ret <- new.env(parent = emptyenv()) } else { .ret <- env } .ret$origData <- data .ret$etaNames <- etaNames .ret$thetaFixed <- fixed .ret$control <- control .ret$control$focei.mu.ref <- integer(0) if (is(model, "RxODE") || is(model, "character")) { .ret$ODEmodel <- TRUE if (class(pred) != "function") { stop("pred must be a function specifying the prediction variables in this model.") } } else { .ret$ODEmodel <- TRUE model <- RxODE::rxGetLin(PKpars) pred <- eval(parse(text = "function(){return(Central);}")) } .square <- function(x) x * x .ret$diagXformInv <- c(sqrt = ".square", log = "exp", identity = "identity")[control$diagXform] if (is.null(err)) { err <- eval(parse(text = paste0("function(){err", paste(inits$ERROR[[1]], collapse = ""), "}"))) } .covNames <- .parNames <- c() .ret$adjLik <- control$adjLik .mixed <- !is.null(inits$OMGA) && length(inits$OMGA) > 0 if (!exists("noLik", envir = .ret)) { .atol <- rep(control$atol, length(RxODE::rxModelVars(model)$state)) .rtol <- rep(control$rtol, length(RxODE::rxModelVars(model)$state)) .ssAtol <- rep(control$ssAtol, length(RxODE::rxModelVars(model)$state)) .ssRtol <- rep(control$ssRtol, length(RxODE::rxModelVars(model)$state)) .ret$model <- RxODE::rxSymPySetupPred(model, pred, PKpars, err, grad = (control$derivMethod == 2L), pred.minus.dv = TRUE, sum.prod = control$sumProd, theta.derivs = FALSE, optExpression = control$optExpression, interaction = (control$interaction == 1L), only.numeric = !.mixed, run.internal = TRUE, addProp = control$addProp) if (!is.null(.ret$model$inner)) { .atol <- c(.atol, rep(control$atolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.atol))) .rtol <- c(.rtol, rep(control$rtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.rtol))) .ret$control$rxControl$atol <- .atol .ret$control$rxControl$rtol <- .rtol .ssAtol <- c(.ssAtol, rep(control$ssAtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.ssAtol))) .ssRtol <- c(.ssRtol, rep(control$ssRtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.ssRtol))) .ret$control$rxControl$ssAtol <- .ssAtol .ret$control$rxControl$ssRtol <- .ssRtol } .covNames <- .parNames <- RxODE::rxParams(.ret$model$pred.only) .covNames <- .covNames[regexpr(rex::rex(start, or("THETA", "ETA"), "[", numbers, "]", end), .covNames) == -1] colnames(data) <- sapply(names(data), function(x) { if (any(x == .covNames)) { return(x) } else { return(toupper(x)) } }) .lhs <- c(names(RxODE::rxInits(.ret$model$pred.only)), RxODE::rxLhs(.ret$model$pred.only)) if (length(.lhs) > 0) { .covNames <- .covNames[regexpr(rex::rex(start, or(.lhs), end), .covNames) == -1] } if (length(.covNames) > 0) { if (!all(.covNames %in% names(data))) { message("Model:") RxODE::rxCat(.ret$model$pred.only) message("Needed Covariates:") nlmixrPrint(.covNames) stop("Not all the covariates are in the dataset.") } message("Needed Covariates:") print(.covNames) } .extraPars <- .ret$model$extra.pars } else { if (.ret$noLik) { .atol <- rep(control$atol, length(RxODE::rxModelVars(model)$state)) .rtol <- rep(control$rtol, length(RxODE::rxModelVars(model)$state)) .ret$model <- RxODE::rxSymPySetupPred(model, pred, PKpars, err, grad = FALSE, pred.minus.dv = TRUE, sum.prod = control$sumProd, theta.derivs = FALSE, optExpression = control$optExpression, run.internal = TRUE, only.numeric = TRUE, addProp = control$addProp) if (!is.null(.ret$model$inner)) { .atol <- c(.atol, rep(control$atolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.atol))) .rtol <- c(.rtol, rep(control$rtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.rtol))) .ret$control$rxControl$atol <- .atol .ret$control$rxControl$rtol <- .rtol } .covNames <- .parNames <- RxODE::rxParams(.ret$model$pred.only) .covNames <- .covNames[regexpr(rex::rex(start, or("THETA", "ETA"), "[", numbers, "]", end), .covNames) == -1] colnames(data) <- sapply(names(data), function(x) { if (any(x == .covNames)) { return(x) } else { return(toupper(x)) } }) .lhs <- c(names(RxODE::rxInits(.ret$model$pred.only)), RxODE::rxLhs(.ret$model$pred.only)) if (length(.lhs) > 0) { .covNames <- .covNames[regexpr(rex::rex(start, or(.lhs), end), .covNames) == -1] } if (length(.covNames) > 0) { if (!all(.covNames %in% names(data))) { message("Model:") RxODE::rxCat(.ret$model$pred.only) message("Needed Covariates:") nlmixrPrint(.covNames) stop("Not all the covariates are in the dataset.") } message("Needed Covariates:") print(.covNames) } .extraPars <- .ret$model$extra.pars } else { .extraPars <- NULL } } .ret$skipCov <- skipCov if (is.null(skipCov)) { if (is.null(fixed)) { .tmp <- rep(FALSE, length(inits$THTA)) } else { if (length(fixed) < length(inits$THTA)) { .tmp <- c(fixed, rep(FALSE, length(inits$THTA) - length(fixed))) } else { .tmp <- fixed[1:length(inits$THTA)] } } if (exists("uif", envir = .ret)) { .uifErr <- .ret$uif$ini$err[!is.na(.ret$uif$ini$ntheta)] .uifErr <- sapply(.uifErr, function(x) { if (is.na(x)) { return(FALSE) } return(!any(x == c("pow2", "tbs", "tbsYj"))) }) .tmp <- (.tmp | .uifErr) } .ret$skipCov <- c(.tmp, rep(TRUE, length(.extraPars))) .ret$control$focei.mu.ref <- .ret$uif$focei.mu.ref } if (is.null(.extraPars)) { .nms <- c(sprintf("THETA[%s]", seq_along(inits$THTA))) } else { .nms <- c(sprintf("THETA[%s]", seq_along(inits$THTA)), sprintf("ERR[%s]", seq_along(.extraPars))) } if (!is.null(thetaNames) && (length(inits$THTA) + length(.extraPars)) == length(thetaNames)) { .nms <- thetaNames } .ret$thetaNames <- .nms .thetaReset$thetaNames <- .nms if (length(lower) == 1) { lower <- rep(lower, length(inits$THTA)) } else if (length(lower) != length(inits$THTA)) { print(inits$THTA) print(lower) stop("Lower must be a single constant for all the THETA lower bounds, or match the dimension of THETA.") } if (length(upper) == 1) { upper <- rep(upper, length(inits$THTA)) } else if (length(lower) != length(inits$THTA)) { stop("Upper must be a single constant for all the THETA lower bounds, or match the dimension of THETA.") } if (!is.null(.extraPars)) { .ret$model$extra.pars <- eval(call(control$diagXform, .ret$model$extra.pars)) if (length(.ret$model$extra.pars) > 0) { inits$THTA <- c(inits$THTA, .ret$model$extra.pars) .lowerErr <- rep(control$atol[1] * 10, length(.ret$model$extra.pars)) .upperErr <- rep(Inf, length(.ret$model$extra.pars)) lower <- c(lower, .lowerErr) upper <- c(upper, .upperErr) } } if (is.null(data$ID)) stop("\"ID\" not found in data") if (is.null(data$DV)) stop("\"DV\" not found in data") if (is.null(data$EVID)) data$EVID <- 0 if (is.null(data$AMT)) data$AMT <- 0 for (.v in c("TIME", "AMT", "DV", .covNames)) { data[[.v]] <- as.double(data[[.v]]) } .ret$dataSav <- data .ds <- data[data$EVID != 0 & data$EVID != 2, c("ID", "TIME", "AMT", "EVID", .covNames)] .w <- which(tolower(names(data)) == "limit") .limitName <- NULL if (length(.w) == 1L) { .limitName <- names(data)[.w] } .censName <- NULL .w <- which(tolower(names(data)) == "cens") if (length(.w) == 1L) { .censName <- names(data[.w]) } data <- data[data$EVID == 0 | data$EVID == 2, c("ID", "TIME", "DV", "EVID", .covNames, .limitName, .censName)] .w <- which(!(names(.ret$dataSav) %in% c(.covNames, keep))) names(.ret$dataSav)[.w] <- tolower(names(.ret$dataSav[.w])) if (.mixed) { .lh <- .parseOM(inits$OMGA) .nlh <- sapply(.lh, length) .osplt <- rep(1:length(.lh), .nlh) .lini <- list(inits$THTA, unlist(.lh)) .nlini <- sapply(.lini, length) .nsplt <- rep(1:length(.lini), .nlini) .om0 <- .genOM(.lh) if (length(etaNames) == dim(.om0)[1]) { .ret$etaNames <- .ret$etaNames } else { .ret$etaNames <- sprintf("ETA[%d]", seq(1, dim(.om0)[1])) } .ret$rxInv <- RxODE::rxSymInvCholCreate(mat = .om0, diag.xform = control$diagXform) .ret$xType <- .ret$rxInv$xType .om0a <- .om0 .om0a <- .om0a/control$diagOmegaBoundLower .om0b <- .om0 .om0b <- .om0b * control$diagOmegaBoundUpper .om0a <- RxODE::rxSymInvCholCreate(mat = .om0a, diag.xform = control$diagXform) .om0b <- RxODE::rxSymInvCholCreate(mat = .om0b, diag.xform = control$diagXform) .omdf <- data.frame(a = .om0a$theta, m = .ret$rxInv$theta, b = .om0b$theta, diag = .om0a$theta.diag) .omdf$lower <- with(.omdf, ifelse(a > b, b, a)) .omdf$lower <- with(.omdf, ifelse(lower == m, -Inf, lower)) .omdf$lower <- with(.omdf, ifelse(!diag, -Inf, lower)) .omdf$upper <- with(.omdf, ifelse(a < b, b, a)) .omdf$upper <- with(.omdf, ifelse(upper == m, Inf, upper)) .omdf$upper <- with(.omdf, ifelse(!diag, Inf, upper)) .ret$control$nomega <- length(.omdf$lower) .ret$control$neta <- sum(.omdf$diag) .ret$control$ntheta <- length(lower) .ret$control$nfixed <- sum(fixed) lower <- c(lower, .omdf$lower) upper <- c(upper, .omdf$upper) } else { .ret$control$nomega <- 0 .ret$control$neta <- 0 .ret$xType <- -1 .ret$control$ntheta <- length(lower) .ret$control$nfixed <- sum(fixed) } .ret$lower <- lower .ret$upper <- upper .ret$thetaIni <- inits$THTA .scaleC <- double(length(lower)) if (is.null(control$scaleC)) { .scaleC <- rep(NA_real_, length(lower)) } else { .scaleC <- as.double(control$scaleC) if (length(lower) > length(.scaleC)) { .scaleC <- c(.scaleC, rep(NA_real_, length(lower) - length(.scaleC))) } else if (length(lower) < length(.scaleC)) { .scaleC <- .scaleC[seq(1, length(lower))] warning("scaleC control option has more options than estimated population parameters, please check.") } } .ret$scaleC <- .scaleC if (exists("uif", envir = .ret)) { .ini <- as.data.frame(.ret$uif$ini)[!is.na(.ret$uif$ini$err), c("est", "err", "ntheta")] for (.i in seq_along(.ini$err)) { if (is.na(.ret$scaleC[.ini$ntheta[.i]])) { if (any(.ini$err[.i] == c("boxCox", "yeoJohnson", "pow2", "tbs", "tbsYj"))) { .ret$scaleC[.ini$ntheta[.i]] <- 1 } else if (any(.ini$err[.i] == c("prop", "add", "norm", "dnorm", "logn", "dlogn", "lnorm", "dlnorm"))) { .ret$scaleC[.ini$ntheta[.i]] <- 0.5 * abs(.ini$est[.i]) } } } for (.i in .ini$model$extraProps$powTheta) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- 1 } .ini <- as.data.frame(.ret$uif$ini) for (.i in .ini$model$extraProps$factorial) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- abs(1/digamma(.ini$est[.i] + 1)) } for (.i in .ini$model$extraProps$gamma) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- abs(1/digamma(.ini$est[.i])) } for (.i in .ini$model$extraProps$log) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- log(abs(.ini$est[.i])) * abs(.ini$est[.i]) } for (.i in .ret$logitThetas) { .b <- .ret$logitThetasLow[.i] .c <- .ret$logitThetasHi[.i] .a <- .ini$est[.i] if (is.na(.ret$scaleC[.i])) { .ret$scaleC[.i] <- 1 * (-.b + .c) * exp(-.a)/((1 + exp(-.a))^2 * (.b + 1 * (-.b + .c)/(1 + exp(-.a)))) } } } names(.ret$thetaIni) <- sprintf("THETA[%d]", seq_along(.ret$thetaIni)) if (is.null(etaMat) & !is.null(control$etaMat)) { .ret$etaMat <- control$etaMat } else { .ret$etaMat <- etaMat } .ret$setupTime <- (proc.time() - .pt)["elapsed"] if (exists("uif", envir = .ret)) { .tmp <- .ret$uif$logThetasList .ret$logThetas <- .tmp[[1]] .ret$logThetasF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasList .ret$logitThetas <- .tmp[[1]] .ret$logitThetasF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasListLow .ret$logitThetasLow <- .tmp[[1]] .ret$logitThetasLowF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasListHi .ret$logitThetasHi <- .tmp[[1]] .ret$logitThetasHiF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasList .ret$probitThetas <- .tmp[[1]] .ret$probitThetasF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasListLow .ret$probitThetasLow <- .tmp[[1]] .ret$probitThetasLowF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasListHi .ret$probitThetasHi <- .tmp[[1]] .ret$probitThetasHiF <- .tmp[[2]] } else { .ret$logThetasF <- integer(0) .ret$logitThetasF <- integer(0) .ret$logitThetasHiF <- numeric(0) .ret$logitThetasLowF <- numeric(0) .ret$logitThetas <- integer(0) .ret$logitThetasHi <- numeric(0) .ret$logitThetasLow <- numeric(0) .ret$probitThetasF <- integer(0) .ret$probitThetasHiF <- numeric(0) .ret$probitThetasLowF <- numeric(0) .ret$probitThetas <- integer(0) .ret$probitThetasHi <- numeric(0) .ret$probitThetasLow <- numeric(0) } if (exists("noLik", envir = .ret)) { if (!.ret$noLik) { .ret$.params <- c(sprintf("THETA[%d]", seq_along(.ret$thetaIni)), sprintf("ETA[%d]", seq(1, dim(.om0)[1]))) .ret$.thetan <- length(.ret$thetaIni) .ret$nobs <- sum(data$EVID == 0) } } .ret$control$printTop <- TRUE .ret$control$nF <- 0 .est0 <- .ret$thetaIni if (!is.null(.ret$model$pred.nolhs)) { .ret$control$predNeq <- length(.ret$model$pred.nolhs$state) } else { .ret$control$predNeq <- 0L } .fitFun <- function(.ret) { this.env <- environment() assign("err", "theta reset", this.env) while (this.env$err == "theta reset") { assign("err", "", this.env) .ret0 <- tryCatch({ foceiFitCpp_(.ret) }, error = function(e) { if (regexpr("theta reset", e$message) != -1) { assign("zeroOuter", FALSE, this.env) assign("zeroGrad", FALSE, this.env) if (regexpr("theta reset0", e$message) != -1) { assign("zeroGrad", TRUE, this.env) } else if (regexpr("theta resetZ", e$message) != -1) { assign("zeroOuter", TRUE, this.env) } assign("err", "theta reset", this.env) } else { assign("err", e$message, this.env) } }) if (this.env$err == "theta reset") { .nm <- names(.ret$thetaIni) .ret$thetaIni <- setNames(.thetaReset$thetaIni + 0, .nm) .ret$rxInv$theta <- .thetaReset$omegaTheta .ret$control$printTop <- FALSE .ret$etaMat <- .thetaReset$etaMat .ret$control$etaMat <- .thetaReset$etaMat .ret$control$maxInnerIterations <- .thetaReset$maxInnerIterations .ret$control$nF <- .thetaReset$nF .ret$control$gillRetC <- .thetaReset$gillRetC .ret$control$gillRet <- .thetaReset$gillRet .ret$control$gillRet <- .thetaReset$gillRet .ret$control$gillDf <- .thetaReset$gillDf .ret$control$gillDf2 <- .thetaReset$gillDf2 .ret$control$gillErr <- .thetaReset$gillErr .ret$control$rEps <- .thetaReset$rEps .ret$control$aEps <- .thetaReset$aEps .ret$control$rEpsC <- .thetaReset$rEpsC .ret$control$aEpsC <- .thetaReset$aEpsC .ret$control$c1 <- .thetaReset$c1 .ret$control$c2 <- .thetaReset$c2 if (this.env$zeroOuter) { message("Posthoc reset") .ret$control$maxOuterIterations <- 0L } else if (this.env$zeroGrad) { message("Theta reset (zero gradient values); Switch to bobyqa") RxODE::rxReq("minqa") .ret$control$outerOptFun <- .bobyqa .ret$control$outerOpt <- -1L } else { message("Theta reset (ETA drift)") } } } if (this.env$err != "") { stop(this.env$err) } else { return(.ret0) } } .ret0 <- try(.fitFun(.ret)) .n <- 1 while (inherits(.ret0, "try-error") && control$maxOuterIterations != 0 && .n <= control$nRetries) { message(sprintf("Restart %s", .n)) .ret$control$nF <- 0 .estNew <- .est0 + 0.2 * .n * abs(.est0) * stats::runif(length(.est0)) - 0.1 * .n .estNew <- sapply(seq_along(.est0), function(.i) { if (.ret$thetaFixed[.i]) { return(.est0[.i]) } else if (.estNew[.i] < lower[.i]) { return(lower + (.Machine$double.eps)^(1/7)) } else if (.estNew[.i] > upper[.i]) { return(upper - (.Machine$double.eps)^(1/7)) } else { return(.estNew[.i]) } }) .ret$thetaIni <- .estNew .ret0 <- try(.fitFun(.ret)) .n <- .n + 1 } if (inherits(.ret0, "try-error")) stop("Could not fit data.") .ret <- .ret0 if (exists("parHistData", .ret)) { .tmp <- .ret$parHistData .tmp <- .tmp[.tmp$type == "Unscaled", names(.tmp) != "type"] .iter <- .tmp$iter .tmp <- .tmp[, names(.tmp) != "iter"] .ret$parHistStacked <- data.frame(stack(.tmp), iter = .iter) names(.ret$parHistStacked) <- c("val", "par", "iter") .ret$parHist <- data.frame(iter = .iter, .tmp) } if (.mixed) { .etas <- .ret$ranef .thetas <- .ret$fixef .pars <- .Call(`_nlmixr_nlmixrParameters`, .thetas, .etas) .ret$shrink <- .Call(`_nlmixr_calcShrinkOnly`, .ret$omega, .pars$eta.lst, length(.etas$ID)) .updateParFixed(.ret) } else { .updateParFixed(.ret) } if (!exists("table", .ret)) { .ret$table <- tableControl() } if (control$calcTables) { .ret <- addTable(.ret, updateObject = "no", keep = keep, drop = drop, table = .ret$table) } .ret})(data = dat, inits = .FoceiInits, PKpars = .pars, model = .mod, pred = function() { return(nlmixr_pred) }, err = uif$error, lower = uif$focei.lower, upper = uif$focei.upper, fixed = uif$focei.fixed, thetaNames = uif$focei.names, etaNames = uif$eta.names, control = control, env = env, keep = .keep, drop = .drop): Not all the covariates are in the dataset.</span></div><div class='output co'>#> <span class='message'>Timing stopped at: 6.93 0.367 7.293</span></div><div class='input'><span class='va'>f_nlmixr_dfop_sfo_focei_const</span> <span class='op'><-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr</a></span><span class='op'>(</span><span class='va'>f_mmkin_const</span><span class='op'>[</span><span class='st'>"DFOP-SFO"</span>, <span class='op'>]</span>, est <span class='op'>=</span> <span class='st'>"focei"</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> parameter labels from comments are typically ignored in non-interactive mode</span></div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> Need to run with the source intact to parse comments</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ calculate jacobian</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate sensitivities</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(f)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(R²)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling inner model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling EBE model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ compiling events FD model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>Model:</span></div><div class='output co'>#> <span class='message'>cmt(parent);</span>
#> <span class='message'>cmt(A1);</span>
#> <span class='message'>rx_expr_6~ETA[1]+THETA[1];</span>
#> <span class='message'>parent(0)=rx_expr_6;</span>
#> <span class='message'>rx_expr_7~ETA[4]+THETA[4];</span>
#> <span class='message'>rx_expr_8~ETA[6]+THETA[6];</span>
#> <span class='message'>rx_expr_9~ETA[5]+THETA[5];</span>
#> <span class='message'>rx_expr_12~exp(rx_expr_7);</span>
#> <span class='message'>rx_expr_13~exp(rx_expr_9);</span>
#> <span class='message'>rx_expr_15~t*rx_expr_12;</span>
#> <span class='message'>rx_expr_16~t*rx_expr_13;</span>
#> <span class='message'>rx_expr_18~exp(-(rx_expr_8));</span>
#> <span class='message'>rx_expr_20~1+rx_expr_18;</span>
#> <span class='message'>rx_expr_25~1/(rx_expr_20);</span>
#> <span class='message'>rx_expr_27~(rx_expr_25);</span>
#> <span class='message'>rx_expr_28~1-rx_expr_27;</span>
#> <span class='message'>d/dt(parent)=-parent*(exp(rx_expr_7-rx_expr_15)/(rx_expr_20)+exp(rx_expr_9-rx_expr_16)*(rx_expr_28))/(exp(-t*rx_expr_12)/(rx_expr_20)+exp(-t*rx_expr_13)*(rx_expr_28));</span>
#> <span class='message'>rx_expr_10~ETA[2]+THETA[2];</span>
#> <span class='message'>rx_expr_14~exp(rx_expr_10);</span>
#> <span class='message'>d/dt(A1)=-rx_expr_14*A1+parent*f_parent_to_A1*(exp(rx_expr_7-rx_expr_15)/(rx_expr_20)+exp(rx_expr_9-rx_expr_16)*(rx_expr_28))/(exp(-t*rx_expr_12)/(rx_expr_20)+exp(-t*rx_expr_13)*(rx_expr_28));</span>
#> <span class='message'>rx_expr_0~CMT==2;</span>
#> <span class='message'>rx_expr_1~CMT==1;</span>
#> <span class='message'>rx_expr_2~1-(rx_expr_0);</span>
#> <span class='message'>rx_yj_~2*(rx_expr_2)*(rx_expr_1)+2*(rx_expr_0);</span>
#> <span class='message'>rx_expr_3~(rx_expr_0);</span>
#> <span class='message'>rx_expr_5~(rx_expr_2);</span>
#> <span class='message'>rx_expr_19~rx_expr_5*(rx_expr_1);</span>
#> <span class='message'>rx_lambda_~rx_expr_19+rx_expr_3;</span>
#> <span class='message'>rx_hi_~rx_expr_19+rx_expr_3;</span>
#> <span class='message'>rx_low_~0;</span>
#> <span class='message'>rx_expr_4~A1*(rx_expr_0);</span>
#> <span class='message'>rx_expr_11~parent*(rx_expr_2);</span>
#> <span class='message'>rx_expr_23~rx_expr_11*(rx_expr_1);</span>
#> <span class='message'>rx_pred_=(rx_expr_4+rx_expr_23)*(rx_expr_0)+(rx_expr_4+rx_expr_23)*(rx_expr_2)*(rx_expr_1);</span>
#> <span class='message'>rx_expr_17~Rx_pow_di(THETA[7],2);</span>
#> <span class='message'>rx_r_=(rx_expr_0)*rx_expr_17+(rx_expr_2)*(rx_expr_1)*rx_expr_17;</span>
#> <span class='message'>parent_0=THETA[1];</span>
#> <span class='message'>log_k_A1=THETA[2];</span>
#> <span class='message'>f_parent_qlogis=THETA[3];</span>
#> <span class='message'>log_k1=THETA[4];</span>
#> <span class='message'>log_k2=THETA[5];</span>
#> <span class='message'>g_qlogis=THETA[6];</span>
#> <span class='message'>sigma=THETA[7];</span>
#> <span class='message'>eta.parent_0=ETA[1];</span>
#> <span class='message'>eta.log_k_A1=ETA[2];</span>
#> <span class='message'>eta.f_parent_qlogis=ETA[3];</span>
#> <span class='message'>eta.log_k1=ETA[4];</span>
#> <span class='message'>eta.log_k2=ETA[5];</span>
#> <span class='message'>eta.g_qlogis=ETA[6];</span>
#> <span class='message'>parent_0_model=rx_expr_6;</span>
#> <span class='message'>k_A1=rx_expr_14;</span>
#> <span class='message'>k1=rx_expr_12;</span>
#> <span class='message'>k2=rx_expr_13;</span>
#> <span class='message'>f_parent=1/(1+exp(-(ETA[3]+THETA[3])));</span>
#> <span class='message'>g=1/(rx_expr_20);</span>
#> <span class='message'>tad=tad();</span>
#> <span class='message'>dosenum=dosenum();</span></div><div class='output co'>#> <span class='message'>Needed Covariates:</span></div><div class='output co'>#> <span class='message'>[1] "f_parent_to_A1" "CMT" </span></div><div class='output co'>#> <span class='error'>Error in (function (data, inits, PKpars, model = NULL, pred = NULL, err = NULL, lower = -Inf, upper = Inf, fixed = NULL, skipCov = NULL, control = foceiControl(), thetaNames = NULL, etaNames = NULL, etaMat = NULL, ..., env = NULL, keep = NULL, drop = NULL) { set.seed(control$seed) .pt <- proc.time() RxODE::.setWarnIdSort(FALSE) on.exit(RxODE::.setWarnIdSort(TRUE)) loadNamespace("n1qn1") if (!RxODE::rxIs(control, "foceiControl")) { control <- do.call(foceiControl, control) } if (is.null(env)) { .ret <- new.env(parent = emptyenv()) } else { .ret <- env } .ret$origData <- data .ret$etaNames <- etaNames .ret$thetaFixed <- fixed .ret$control <- control .ret$control$focei.mu.ref <- integer(0) if (is(model, "RxODE") || is(model, "character")) { .ret$ODEmodel <- TRUE if (class(pred) != "function") { stop("pred must be a function specifying the prediction variables in this model.") } } else { .ret$ODEmodel <- TRUE model <- RxODE::rxGetLin(PKpars) pred <- eval(parse(text = "function(){return(Central);}")) } .square <- function(x) x * x .ret$diagXformInv <- c(sqrt = ".square", log = "exp", identity = "identity")[control$diagXform] if (is.null(err)) { err <- eval(parse(text = paste0("function(){err", paste(inits$ERROR[[1]], collapse = ""), "}"))) } .covNames <- .parNames <- c() .ret$adjLik <- control$adjLik .mixed <- !is.null(inits$OMGA) && length(inits$OMGA) > 0 if (!exists("noLik", envir = .ret)) { .atol <- rep(control$atol, length(RxODE::rxModelVars(model)$state)) .rtol <- rep(control$rtol, length(RxODE::rxModelVars(model)$state)) .ssAtol <- rep(control$ssAtol, length(RxODE::rxModelVars(model)$state)) .ssRtol <- rep(control$ssRtol, length(RxODE::rxModelVars(model)$state)) .ret$model <- RxODE::rxSymPySetupPred(model, pred, PKpars, err, grad = (control$derivMethod == 2L), pred.minus.dv = TRUE, sum.prod = control$sumProd, theta.derivs = FALSE, optExpression = control$optExpression, interaction = (control$interaction == 1L), only.numeric = !.mixed, run.internal = TRUE, addProp = control$addProp) if (!is.null(.ret$model$inner)) { .atol <- c(.atol, rep(control$atolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.atol))) .rtol <- c(.rtol, rep(control$rtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.rtol))) .ret$control$rxControl$atol <- .atol .ret$control$rxControl$rtol <- .rtol .ssAtol <- c(.ssAtol, rep(control$ssAtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.ssAtol))) .ssRtol <- c(.ssRtol, rep(control$ssRtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.ssRtol))) .ret$control$rxControl$ssAtol <- .ssAtol .ret$control$rxControl$ssRtol <- .ssRtol } .covNames <- .parNames <- RxODE::rxParams(.ret$model$pred.only) .covNames <- .covNames[regexpr(rex::rex(start, or("THETA", "ETA"), "[", numbers, "]", end), .covNames) == -1] colnames(data) <- sapply(names(data), function(x) { if (any(x == .covNames)) { return(x) } else { return(toupper(x)) } }) .lhs <- c(names(RxODE::rxInits(.ret$model$pred.only)), RxODE::rxLhs(.ret$model$pred.only)) if (length(.lhs) > 0) { .covNames <- .covNames[regexpr(rex::rex(start, or(.lhs), end), .covNames) == -1] } if (length(.covNames) > 0) { if (!all(.covNames %in% names(data))) { message("Model:") RxODE::rxCat(.ret$model$pred.only) message("Needed Covariates:") nlmixrPrint(.covNames) stop("Not all the covariates are in the dataset.") } message("Needed Covariates:") print(.covNames) } .extraPars <- .ret$model$extra.pars } else { if (.ret$noLik) { .atol <- rep(control$atol, length(RxODE::rxModelVars(model)$state)) .rtol <- rep(control$rtol, length(RxODE::rxModelVars(model)$state)) .ret$model <- RxODE::rxSymPySetupPred(model, pred, PKpars, err, grad = FALSE, pred.minus.dv = TRUE, sum.prod = control$sumProd, theta.derivs = FALSE, optExpression = control$optExpression, run.internal = TRUE, only.numeric = TRUE, addProp = control$addProp) if (!is.null(.ret$model$inner)) { .atol <- c(.atol, rep(control$atolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.atol))) .rtol <- c(.rtol, rep(control$rtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.rtol))) .ret$control$rxControl$atol <- .atol .ret$control$rxControl$rtol <- .rtol } .covNames <- .parNames <- RxODE::rxParams(.ret$model$pred.only) .covNames <- .covNames[regexpr(rex::rex(start, or("THETA", "ETA"), "[", numbers, "]", end), .covNames) == -1] colnames(data) <- sapply(names(data), function(x) { if (any(x == .covNames)) { return(x) } else { return(toupper(x)) } }) .lhs <- c(names(RxODE::rxInits(.ret$model$pred.only)), RxODE::rxLhs(.ret$model$pred.only)) if (length(.lhs) > 0) { .covNames <- .covNames[regexpr(rex::rex(start, or(.lhs), end), .covNames) == -1] } if (length(.covNames) > 0) { if (!all(.covNames %in% names(data))) { message("Model:") RxODE::rxCat(.ret$model$pred.only) message("Needed Covariates:") nlmixrPrint(.covNames) stop("Not all the covariates are in the dataset.") } message("Needed Covariates:") print(.covNames) } .extraPars <- .ret$model$extra.pars } else { .extraPars <- NULL } } .ret$skipCov <- skipCov if (is.null(skipCov)) { if (is.null(fixed)) { .tmp <- rep(FALSE, length(inits$THTA)) } else { if (length(fixed) < length(inits$THTA)) { .tmp <- c(fixed, rep(FALSE, length(inits$THTA) - length(fixed))) } else { .tmp <- fixed[1:length(inits$THTA)] } } if (exists("uif", envir = .ret)) { .uifErr <- .ret$uif$ini$err[!is.na(.ret$uif$ini$ntheta)] .uifErr <- sapply(.uifErr, function(x) { if (is.na(x)) { return(FALSE) } return(!any(x == c("pow2", "tbs", "tbsYj"))) }) .tmp <- (.tmp | .uifErr) } .ret$skipCov <- c(.tmp, rep(TRUE, length(.extraPars))) .ret$control$focei.mu.ref <- .ret$uif$focei.mu.ref } if (is.null(.extraPars)) { .nms <- c(sprintf("THETA[%s]", seq_along(inits$THTA))) } else { .nms <- c(sprintf("THETA[%s]", seq_along(inits$THTA)), sprintf("ERR[%s]", seq_along(.extraPars))) } if (!is.null(thetaNames) && (length(inits$THTA) + length(.extraPars)) == length(thetaNames)) { .nms <- thetaNames } .ret$thetaNames <- .nms .thetaReset$thetaNames <- .nms if (length(lower) == 1) { lower <- rep(lower, length(inits$THTA)) } else if (length(lower) != length(inits$THTA)) { print(inits$THTA) print(lower) stop("Lower must be a single constant for all the THETA lower bounds, or match the dimension of THETA.") } if (length(upper) == 1) { upper <- rep(upper, length(inits$THTA)) } else if (length(lower) != length(inits$THTA)) { stop("Upper must be a single constant for all the THETA lower bounds, or match the dimension of THETA.") } if (!is.null(.extraPars)) { .ret$model$extra.pars <- eval(call(control$diagXform, .ret$model$extra.pars)) if (length(.ret$model$extra.pars) > 0) { inits$THTA <- c(inits$THTA, .ret$model$extra.pars) .lowerErr <- rep(control$atol[1] * 10, length(.ret$model$extra.pars)) .upperErr <- rep(Inf, length(.ret$model$extra.pars)) lower <- c(lower, .lowerErr) upper <- c(upper, .upperErr) } } if (is.null(data$ID)) stop("\"ID\" not found in data") if (is.null(data$DV)) stop("\"DV\" not found in data") if (is.null(data$EVID)) data$EVID <- 0 if (is.null(data$AMT)) data$AMT <- 0 for (.v in c("TIME", "AMT", "DV", .covNames)) { data[[.v]] <- as.double(data[[.v]]) } .ret$dataSav <- data .ds <- data[data$EVID != 0 & data$EVID != 2, c("ID", "TIME", "AMT", "EVID", .covNames)] .w <- which(tolower(names(data)) == "limit") .limitName <- NULL if (length(.w) == 1L) { .limitName <- names(data)[.w] } .censName <- NULL .w <- which(tolower(names(data)) == "cens") if (length(.w) == 1L) { .censName <- names(data[.w]) } data <- data[data$EVID == 0 | data$EVID == 2, c("ID", "TIME", "DV", "EVID", .covNames, .limitName, .censName)] .w <- which(!(names(.ret$dataSav) %in% c(.covNames, keep))) names(.ret$dataSav)[.w] <- tolower(names(.ret$dataSav[.w])) if (.mixed) { .lh <- .parseOM(inits$OMGA) .nlh <- sapply(.lh, length) .osplt <- rep(1:length(.lh), .nlh) .lini <- list(inits$THTA, unlist(.lh)) .nlini <- sapply(.lini, length) .nsplt <- rep(1:length(.lini), .nlini) .om0 <- .genOM(.lh) if (length(etaNames) == dim(.om0)[1]) { .ret$etaNames <- .ret$etaNames } else { .ret$etaNames <- sprintf("ETA[%d]", seq(1, dim(.om0)[1])) } .ret$rxInv <- RxODE::rxSymInvCholCreate(mat = .om0, diag.xform = control$diagXform) .ret$xType <- .ret$rxInv$xType .om0a <- .om0 .om0a <- .om0a/control$diagOmegaBoundLower .om0b <- .om0 .om0b <- .om0b * control$diagOmegaBoundUpper .om0a <- RxODE::rxSymInvCholCreate(mat = .om0a, diag.xform = control$diagXform) .om0b <- RxODE::rxSymInvCholCreate(mat = .om0b, diag.xform = control$diagXform) .omdf <- data.frame(a = .om0a$theta, m = .ret$rxInv$theta, b = .om0b$theta, diag = .om0a$theta.diag) .omdf$lower <- with(.omdf, ifelse(a > b, b, a)) .omdf$lower <- with(.omdf, ifelse(lower == m, -Inf, lower)) .omdf$lower <- with(.omdf, ifelse(!diag, -Inf, lower)) .omdf$upper <- with(.omdf, ifelse(a < b, b, a)) .omdf$upper <- with(.omdf, ifelse(upper == m, Inf, upper)) .omdf$upper <- with(.omdf, ifelse(!diag, Inf, upper)) .ret$control$nomega <- length(.omdf$lower) .ret$control$neta <- sum(.omdf$diag) .ret$control$ntheta <- length(lower) .ret$control$nfixed <- sum(fixed) lower <- c(lower, .omdf$lower) upper <- c(upper, .omdf$upper) } else { .ret$control$nomega <- 0 .ret$control$neta <- 0 .ret$xType <- -1 .ret$control$ntheta <- length(lower) .ret$control$nfixed <- sum(fixed) } .ret$lower <- lower .ret$upper <- upper .ret$thetaIni <- inits$THTA .scaleC <- double(length(lower)) if (is.null(control$scaleC)) { .scaleC <- rep(NA_real_, length(lower)) } else { .scaleC <- as.double(control$scaleC) if (length(lower) > length(.scaleC)) { .scaleC <- c(.scaleC, rep(NA_real_, length(lower) - length(.scaleC))) } else if (length(lower) < length(.scaleC)) { .scaleC <- .scaleC[seq(1, length(lower))] warning("scaleC control option has more options than estimated population parameters, please check.") } } .ret$scaleC <- .scaleC if (exists("uif", envir = .ret)) { .ini <- as.data.frame(.ret$uif$ini)[!is.na(.ret$uif$ini$err), c("est", "err", "ntheta")] for (.i in seq_along(.ini$err)) { if (is.na(.ret$scaleC[.ini$ntheta[.i]])) { if (any(.ini$err[.i] == c("boxCox", "yeoJohnson", "pow2", "tbs", "tbsYj"))) { .ret$scaleC[.ini$ntheta[.i]] <- 1 } else if (any(.ini$err[.i] == c("prop", "add", "norm", "dnorm", "logn", "dlogn", "lnorm", "dlnorm"))) { .ret$scaleC[.ini$ntheta[.i]] <- 0.5 * abs(.ini$est[.i]) } } } for (.i in .ini$model$extraProps$powTheta) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- 1 } .ini <- as.data.frame(.ret$uif$ini) for (.i in .ini$model$extraProps$factorial) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- abs(1/digamma(.ini$est[.i] + 1)) } for (.i in .ini$model$extraProps$gamma) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- abs(1/digamma(.ini$est[.i])) } for (.i in .ini$model$extraProps$log) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- log(abs(.ini$est[.i])) * abs(.ini$est[.i]) } for (.i in .ret$logitThetas) { .b <- .ret$logitThetasLow[.i] .c <- .ret$logitThetasHi[.i] .a <- .ini$est[.i] if (is.na(.ret$scaleC[.i])) { .ret$scaleC[.i] <- 1 * (-.b + .c) * exp(-.a)/((1 + exp(-.a))^2 * (.b + 1 * (-.b + .c)/(1 + exp(-.a)))) } } } names(.ret$thetaIni) <- sprintf("THETA[%d]", seq_along(.ret$thetaIni)) if (is.null(etaMat) & !is.null(control$etaMat)) { .ret$etaMat <- control$etaMat } else { .ret$etaMat <- etaMat } .ret$setupTime <- (proc.time() - .pt)["elapsed"] if (exists("uif", envir = .ret)) { .tmp <- .ret$uif$logThetasList .ret$logThetas <- .tmp[[1]] .ret$logThetasF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasList .ret$logitThetas <- .tmp[[1]] .ret$logitThetasF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasListLow .ret$logitThetasLow <- .tmp[[1]] .ret$logitThetasLowF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasListHi .ret$logitThetasHi <- .tmp[[1]] .ret$logitThetasHiF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasList .ret$probitThetas <- .tmp[[1]] .ret$probitThetasF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasListLow .ret$probitThetasLow <- .tmp[[1]] .ret$probitThetasLowF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasListHi .ret$probitThetasHi <- .tmp[[1]] .ret$probitThetasHiF <- .tmp[[2]] } else { .ret$logThetasF <- integer(0) .ret$logitThetasF <- integer(0) .ret$logitThetasHiF <- numeric(0) .ret$logitThetasLowF <- numeric(0) .ret$logitThetas <- integer(0) .ret$logitThetasHi <- numeric(0) .ret$logitThetasLow <- numeric(0) .ret$probitThetasF <- integer(0) .ret$probitThetasHiF <- numeric(0) .ret$probitThetasLowF <- numeric(0) .ret$probitThetas <- integer(0) .ret$probitThetasHi <- numeric(0) .ret$probitThetasLow <- numeric(0) } if (exists("noLik", envir = .ret)) { if (!.ret$noLik) { .ret$.params <- c(sprintf("THETA[%d]", seq_along(.ret$thetaIni)), sprintf("ETA[%d]", seq(1, dim(.om0)[1]))) .ret$.thetan <- length(.ret$thetaIni) .ret$nobs <- sum(data$EVID == 0) } } .ret$control$printTop <- TRUE .ret$control$nF <- 0 .est0 <- .ret$thetaIni if (!is.null(.ret$model$pred.nolhs)) { .ret$control$predNeq <- length(.ret$model$pred.nolhs$state) } else { .ret$control$predNeq <- 0L } .fitFun <- function(.ret) { this.env <- environment() assign("err", "theta reset", this.env) while (this.env$err == "theta reset") { assign("err", "", this.env) .ret0 <- tryCatch({ foceiFitCpp_(.ret) }, error = function(e) { if (regexpr("theta reset", e$message) != -1) { assign("zeroOuter", FALSE, this.env) assign("zeroGrad", FALSE, this.env) if (regexpr("theta reset0", e$message) != -1) { assign("zeroGrad", TRUE, this.env) } else if (regexpr("theta resetZ", e$message) != -1) { assign("zeroOuter", TRUE, this.env) } assign("err", "theta reset", this.env) } else { assign("err", e$message, this.env) } }) if (this.env$err == "theta reset") { .nm <- names(.ret$thetaIni) .ret$thetaIni <- setNames(.thetaReset$thetaIni + 0, .nm) .ret$rxInv$theta <- .thetaReset$omegaTheta .ret$control$printTop <- FALSE .ret$etaMat <- .thetaReset$etaMat .ret$control$etaMat <- .thetaReset$etaMat .ret$control$maxInnerIterations <- .thetaReset$maxInnerIterations .ret$control$nF <- .thetaReset$nF .ret$control$gillRetC <- .thetaReset$gillRetC .ret$control$gillRet <- .thetaReset$gillRet .ret$control$gillRet <- .thetaReset$gillRet .ret$control$gillDf <- .thetaReset$gillDf .ret$control$gillDf2 <- .thetaReset$gillDf2 .ret$control$gillErr <- .thetaReset$gillErr .ret$control$rEps <- .thetaReset$rEps .ret$control$aEps <- .thetaReset$aEps .ret$control$rEpsC <- .thetaReset$rEpsC .ret$control$aEpsC <- .thetaReset$aEpsC .ret$control$c1 <- .thetaReset$c1 .ret$control$c2 <- .thetaReset$c2 if (this.env$zeroOuter) { message("Posthoc reset") .ret$control$maxOuterIterations <- 0L } else if (this.env$zeroGrad) { message("Theta reset (zero gradient values); Switch to bobyqa") RxODE::rxReq("minqa") .ret$control$outerOptFun <- .bobyqa .ret$control$outerOpt <- -1L } else { message("Theta reset (ETA drift)") } } } if (this.env$err != "") { stop(this.env$err) } else { return(.ret0) } } .ret0 <- try(.fitFun(.ret)) .n <- 1 while (inherits(.ret0, "try-error") && control$maxOuterIterations != 0 && .n <= control$nRetries) { message(sprintf("Restart %s", .n)) .ret$control$nF <- 0 .estNew <- .est0 + 0.2 * .n * abs(.est0) * stats::runif(length(.est0)) - 0.1 * .n .estNew <- sapply(seq_along(.est0), function(.i) { if (.ret$thetaFixed[.i]) { return(.est0[.i]) } else if (.estNew[.i] < lower[.i]) { return(lower + (.Machine$double.eps)^(1/7)) } else if (.estNew[.i] > upper[.i]) { return(upper - (.Machine$double.eps)^(1/7)) } else { return(.estNew[.i]) } }) .ret$thetaIni <- .estNew .ret0 <- try(.fitFun(.ret)) .n <- .n + 1 } if (inherits(.ret0, "try-error")) stop("Could not fit data.") .ret <- .ret0 if (exists("parHistData", .ret)) { .tmp <- .ret$parHistData .tmp <- .tmp[.tmp$type == "Unscaled", names(.tmp) != "type"] .iter <- .tmp$iter .tmp <- .tmp[, names(.tmp) != "iter"] .ret$parHistStacked <- data.frame(stack(.tmp), iter = .iter) names(.ret$parHistStacked) <- c("val", "par", "iter") .ret$parHist <- data.frame(iter = .iter, .tmp) } if (.mixed) { .etas <- .ret$ranef .thetas <- .ret$fixef .pars <- .Call(`_nlmixr_nlmixrParameters`, .thetas, .etas) .ret$shrink <- .Call(`_nlmixr_calcShrinkOnly`, .ret$omega, .pars$eta.lst, length(.etas$ID)) .updateParFixed(.ret) } else { .updateParFixed(.ret) } if (!exists("table", .ret)) { .ret$table <- tableControl() } if (control$calcTables) { .ret <- addTable(.ret, updateObject = "no", keep = keep, drop = drop, table = .ret$table) } .ret})(data = dat, inits = .FoceiInits, PKpars = .pars, model = .mod, pred = function() { return(nlmixr_pred) }, err = uif$error, lower = uif$focei.lower, upper = uif$focei.upper, fixed = uif$focei.fixed, thetaNames = uif$focei.names, etaNames = uif$eta.names, control = control, env = env, keep = .keep, drop = .drop): Not all the covariates are in the dataset.</span></div><div class='output co'>#> <span class='message'>Timing stopped at: 15.39 1.223 16.61</span></div><div class='input'>
<span class='co'># Variance by variable is supported by 'saem' and 'focei'</span>
<span class='va'>f_nlmixr_fomc_sfo_saem_obs</span> <span class='op'><-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr</a></span><span class='op'>(</span><span class='va'>f_mmkin_obs</span><span class='op'>[</span><span class='st'>"FOMC-SFO"</span>, <span class='op'>]</span>, est <span class='op'>=</span> <span class='st'>"saem"</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> parameter labels from comments are typically ignored in non-interactive mode</span></div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> Need to run with the source intact to parse comments</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'>→ generate SAEM model</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='error'>Error in configsaem(model = model, data = dat, inits = inits, mcmc = .mcmc, ODEopt = .ODEopt, seed = .seed, distribution = .dist, DEBUG = .DEBUG, addProp = .addProp, tol = .tol, itmax = .itmax, type = .type, powRange = .powRange, lambdaRange = .lambdaRange): covariate(s) not found: f_parent_to_A1</span></div><div class='output co'>#> <span class='message'>Timing stopped at: 1.288 0.09 1.379</span></div><div class='input'><span class='va'>f_nlmixr_fomc_sfo_focei_obs</span> <span class='op'><-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr</a></span><span class='op'>(</span><span class='va'>f_mmkin_obs</span><span class='op'>[</span><span class='st'>"FOMC-SFO"</span>, <span class='op'>]</span>, est <span class='op'>=</span> <span class='st'>"focei"</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> parameter labels from comments are typically ignored in non-interactive mode</span></div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> Need to run with the source intact to parse comments</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ calculate jacobian</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate sensitivities</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(f)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(R²)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling inner model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling EBE model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ compiling events FD model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>Model:</span></div><div class='output co'>#> <span class='message'>cmt(parent);</span>
#> <span class='message'>cmt(A1);</span>
#> <span class='message'>rx_expr_6~ETA[1]+THETA[1];</span>
#> <span class='message'>parent(0)=rx_expr_6;</span>
#> <span class='message'>rx_expr_7~ETA[4]+THETA[4];</span>
#> <span class='message'>rx_expr_8~ETA[5]+THETA[5];</span>
#> <span class='message'>rx_expr_12~exp(-(rx_expr_8));</span>
#> <span class='message'>rx_expr_14~t*rx_expr_12;</span>
#> <span class='message'>rx_expr_15~1+rx_expr_14;</span>
#> <span class='message'>rx_expr_17~rx_expr_7-(rx_expr_8);</span>
#> <span class='message'>rx_expr_19~exp(rx_expr_17);</span>
#> <span class='message'>d/dt(parent)=-rx_expr_19*parent/(rx_expr_15);</span>
#> <span class='message'>rx_expr_9~ETA[2]+THETA[2];</span>
#> <span class='message'>rx_expr_11~exp(rx_expr_9);</span>
#> <span class='message'>d/dt(A1)=-rx_expr_11*A1+rx_expr_19*parent*f_parent_to_A1/(rx_expr_15);</span>
#> <span class='message'>rx_expr_0~CMT==2;</span>
#> <span class='message'>rx_expr_1~CMT==1;</span>
#> <span class='message'>rx_expr_2~1-(rx_expr_0);</span>
#> <span class='message'>rx_yj_~2*(rx_expr_2)*(rx_expr_1)+2*(rx_expr_0);</span>
#> <span class='message'>rx_expr_3~(rx_expr_0);</span>
#> <span class='message'>rx_expr_5~(rx_expr_2);</span>
#> <span class='message'>rx_expr_13~rx_expr_5*(rx_expr_1);</span>
#> <span class='message'>rx_lambda_~rx_expr_13+rx_expr_3;</span>
#> <span class='message'>rx_hi_~rx_expr_13+rx_expr_3;</span>
#> <span class='message'>rx_low_~0;</span>
#> <span class='message'>rx_expr_4~A1*(rx_expr_0);</span>
#> <span class='message'>rx_expr_10~parent*(rx_expr_2);</span>
#> <span class='message'>rx_expr_16~rx_expr_10*(rx_expr_1);</span>
#> <span class='message'>rx_pred_=(rx_expr_4+rx_expr_16)*(rx_expr_0)+(rx_expr_4+rx_expr_16)*(rx_expr_2)*(rx_expr_1);</span>
#> <span class='message'>rx_r_=(rx_expr_0)*Rx_pow_di(THETA[7],2)+(rx_expr_2)*(rx_expr_1)*Rx_pow_di(THETA[6],2);</span>
#> <span class='message'>parent_0=THETA[1];</span>
#> <span class='message'>log_k_A1=THETA[2];</span>
#> <span class='message'>f_parent_qlogis=THETA[3];</span>
#> <span class='message'>log_alpha=THETA[4];</span>
#> <span class='message'>log_beta=THETA[5];</span>
#> <span class='message'>sigma_parent=THETA[6];</span>
#> <span class='message'>sigma_A1=THETA[7];</span>
#> <span class='message'>eta.parent_0=ETA[1];</span>
#> <span class='message'>eta.log_k_A1=ETA[2];</span>
#> <span class='message'>eta.f_parent_qlogis=ETA[3];</span>
#> <span class='message'>eta.log_alpha=ETA[4];</span>
#> <span class='message'>eta.log_beta=ETA[5];</span>
#> <span class='message'>parent_0_model=rx_expr_6;</span>
#> <span class='message'>k_A1=rx_expr_11;</span>
#> <span class='message'>alpha=exp(rx_expr_7);</span>
#> <span class='message'>beta=exp(rx_expr_8);</span>
#> <span class='message'>f_parent=1/(1+exp(-(ETA[3]+THETA[3])));</span>
#> <span class='message'>tad=tad();</span>
#> <span class='message'>dosenum=dosenum();</span></div><div class='output co'>#> <span class='message'>Needed Covariates:</span></div><div class='output co'>#> <span class='message'>[1] "f_parent_to_A1" "CMT" </span></div><div class='output co'>#> <span class='error'>Error in (function (data, inits, PKpars, model = NULL, pred = NULL, err = NULL, lower = -Inf, upper = Inf, fixed = NULL, skipCov = NULL, control = foceiControl(), thetaNames = NULL, etaNames = NULL, etaMat = NULL, ..., env = NULL, keep = NULL, drop = NULL) { set.seed(control$seed) .pt <- proc.time() RxODE::.setWarnIdSort(FALSE) on.exit(RxODE::.setWarnIdSort(TRUE)) loadNamespace("n1qn1") if (!RxODE::rxIs(control, "foceiControl")) { control <- do.call(foceiControl, control) } if (is.null(env)) { .ret <- new.env(parent = emptyenv()) } else { .ret <- env } .ret$origData <- data .ret$etaNames <- etaNames .ret$thetaFixed <- fixed .ret$control <- control .ret$control$focei.mu.ref <- integer(0) if (is(model, "RxODE") || is(model, "character")) { .ret$ODEmodel <- TRUE if (class(pred) != "function") { stop("pred must be a function specifying the prediction variables in this model.") } } else { .ret$ODEmodel <- TRUE model <- RxODE::rxGetLin(PKpars) pred <- eval(parse(text = "function(){return(Central);}")) } .square <- function(x) x * x .ret$diagXformInv <- c(sqrt = ".square", log = "exp", identity = "identity")[control$diagXform] if (is.null(err)) { err <- eval(parse(text = paste0("function(){err", paste(inits$ERROR[[1]], collapse = ""), "}"))) } .covNames <- .parNames <- c() .ret$adjLik <- control$adjLik .mixed <- !is.null(inits$OMGA) && length(inits$OMGA) > 0 if (!exists("noLik", envir = .ret)) { .atol <- rep(control$atol, length(RxODE::rxModelVars(model)$state)) .rtol <- rep(control$rtol, length(RxODE::rxModelVars(model)$state)) .ssAtol <- rep(control$ssAtol, length(RxODE::rxModelVars(model)$state)) .ssRtol <- rep(control$ssRtol, length(RxODE::rxModelVars(model)$state)) .ret$model <- RxODE::rxSymPySetupPred(model, pred, PKpars, err, grad = (control$derivMethod == 2L), pred.minus.dv = TRUE, sum.prod = control$sumProd, theta.derivs = FALSE, optExpression = control$optExpression, interaction = (control$interaction == 1L), only.numeric = !.mixed, run.internal = TRUE, addProp = control$addProp) if (!is.null(.ret$model$inner)) { .atol <- c(.atol, rep(control$atolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.atol))) .rtol <- c(.rtol, rep(control$rtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.rtol))) .ret$control$rxControl$atol <- .atol .ret$control$rxControl$rtol <- .rtol .ssAtol <- c(.ssAtol, rep(control$ssAtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.ssAtol))) .ssRtol <- c(.ssRtol, rep(control$ssRtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.ssRtol))) .ret$control$rxControl$ssAtol <- .ssAtol .ret$control$rxControl$ssRtol <- .ssRtol } .covNames <- .parNames <- RxODE::rxParams(.ret$model$pred.only) .covNames <- .covNames[regexpr(rex::rex(start, or("THETA", "ETA"), "[", numbers, "]", end), .covNames) == -1] colnames(data) <- sapply(names(data), function(x) { if (any(x == .covNames)) { return(x) } else { return(toupper(x)) } }) .lhs <- c(names(RxODE::rxInits(.ret$model$pred.only)), RxODE::rxLhs(.ret$model$pred.only)) if (length(.lhs) > 0) { .covNames <- .covNames[regexpr(rex::rex(start, or(.lhs), end), .covNames) == -1] } if (length(.covNames) > 0) { if (!all(.covNames %in% names(data))) { message("Model:") RxODE::rxCat(.ret$model$pred.only) message("Needed Covariates:") nlmixrPrint(.covNames) stop("Not all the covariates are in the dataset.") } message("Needed Covariates:") print(.covNames) } .extraPars <- .ret$model$extra.pars } else { if (.ret$noLik) { .atol <- rep(control$atol, length(RxODE::rxModelVars(model)$state)) .rtol <- rep(control$rtol, length(RxODE::rxModelVars(model)$state)) .ret$model <- RxODE::rxSymPySetupPred(model, pred, PKpars, err, grad = FALSE, pred.minus.dv = TRUE, sum.prod = control$sumProd, theta.derivs = FALSE, optExpression = control$optExpression, run.internal = TRUE, only.numeric = TRUE, addProp = control$addProp) if (!is.null(.ret$model$inner)) { .atol <- c(.atol, rep(control$atolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.atol))) .rtol <- c(.rtol, rep(control$rtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.rtol))) .ret$control$rxControl$atol <- .atol .ret$control$rxControl$rtol <- .rtol } .covNames <- .parNames <- RxODE::rxParams(.ret$model$pred.only) .covNames <- .covNames[regexpr(rex::rex(start, or("THETA", "ETA"), "[", numbers, "]", end), .covNames) == -1] colnames(data) <- sapply(names(data), function(x) { if (any(x == .covNames)) { return(x) } else { return(toupper(x)) } }) .lhs <- c(names(RxODE::rxInits(.ret$model$pred.only)), RxODE::rxLhs(.ret$model$pred.only)) if (length(.lhs) > 0) { .covNames <- .covNames[regexpr(rex::rex(start, or(.lhs), end), .covNames) == -1] } if (length(.covNames) > 0) { if (!all(.covNames %in% names(data))) { message("Model:") RxODE::rxCat(.ret$model$pred.only) message("Needed Covariates:") nlmixrPrint(.covNames) stop("Not all the covariates are in the dataset.") } message("Needed Covariates:") print(.covNames) } .extraPars <- .ret$model$extra.pars } else { .extraPars <- NULL } } .ret$skipCov <- skipCov if (is.null(skipCov)) { if (is.null(fixed)) { .tmp <- rep(FALSE, length(inits$THTA)) } else { if (length(fixed) < length(inits$THTA)) { .tmp <- c(fixed, rep(FALSE, length(inits$THTA) - length(fixed))) } else { .tmp <- fixed[1:length(inits$THTA)] } } if (exists("uif", envir = .ret)) { .uifErr <- .ret$uif$ini$err[!is.na(.ret$uif$ini$ntheta)] .uifErr <- sapply(.uifErr, function(x) { if (is.na(x)) { return(FALSE) } return(!any(x == c("pow2", "tbs", "tbsYj"))) }) .tmp <- (.tmp | .uifErr) } .ret$skipCov <- c(.tmp, rep(TRUE, length(.extraPars))) .ret$control$focei.mu.ref <- .ret$uif$focei.mu.ref } if (is.null(.extraPars)) { .nms <- c(sprintf("THETA[%s]", seq_along(inits$THTA))) } else { .nms <- c(sprintf("THETA[%s]", seq_along(inits$THTA)), sprintf("ERR[%s]", seq_along(.extraPars))) } if (!is.null(thetaNames) && (length(inits$THTA) + length(.extraPars)) == length(thetaNames)) { .nms <- thetaNames } .ret$thetaNames <- .nms .thetaReset$thetaNames <- .nms if (length(lower) == 1) { lower <- rep(lower, length(inits$THTA)) } else if (length(lower) != length(inits$THTA)) { print(inits$THTA) print(lower) stop("Lower must be a single constant for all the THETA lower bounds, or match the dimension of THETA.") } if (length(upper) == 1) { upper <- rep(upper, length(inits$THTA)) } else if (length(lower) != length(inits$THTA)) { stop("Upper must be a single constant for all the THETA lower bounds, or match the dimension of THETA.") } if (!is.null(.extraPars)) { .ret$model$extra.pars <- eval(call(control$diagXform, .ret$model$extra.pars)) if (length(.ret$model$extra.pars) > 0) { inits$THTA <- c(inits$THTA, .ret$model$extra.pars) .lowerErr <- rep(control$atol[1] * 10, length(.ret$model$extra.pars)) .upperErr <- rep(Inf, length(.ret$model$extra.pars)) lower <- c(lower, .lowerErr) upper <- c(upper, .upperErr) } } if (is.null(data$ID)) stop("\"ID\" not found in data") if (is.null(data$DV)) stop("\"DV\" not found in data") if (is.null(data$EVID)) data$EVID <- 0 if (is.null(data$AMT)) data$AMT <- 0 for (.v in c("TIME", "AMT", "DV", .covNames)) { data[[.v]] <- as.double(data[[.v]]) } .ret$dataSav <- data .ds <- data[data$EVID != 0 & data$EVID != 2, c("ID", "TIME", "AMT", "EVID", .covNames)] .w <- which(tolower(names(data)) == "limit") .limitName <- NULL if (length(.w) == 1L) { .limitName <- names(data)[.w] } .censName <- NULL .w <- which(tolower(names(data)) == "cens") if (length(.w) == 1L) { .censName <- names(data[.w]) } data <- data[data$EVID == 0 | data$EVID == 2, c("ID", "TIME", "DV", "EVID", .covNames, .limitName, .censName)] .w <- which(!(names(.ret$dataSav) %in% c(.covNames, keep))) names(.ret$dataSav)[.w] <- tolower(names(.ret$dataSav[.w])) if (.mixed) { .lh <- .parseOM(inits$OMGA) .nlh <- sapply(.lh, length) .osplt <- rep(1:length(.lh), .nlh) .lini <- list(inits$THTA, unlist(.lh)) .nlini <- sapply(.lini, length) .nsplt <- rep(1:length(.lini), .nlini) .om0 <- .genOM(.lh) if (length(etaNames) == dim(.om0)[1]) { .ret$etaNames <- .ret$etaNames } else { .ret$etaNames <- sprintf("ETA[%d]", seq(1, dim(.om0)[1])) } .ret$rxInv <- RxODE::rxSymInvCholCreate(mat = .om0, diag.xform = control$diagXform) .ret$xType <- .ret$rxInv$xType .om0a <- .om0 .om0a <- .om0a/control$diagOmegaBoundLower .om0b <- .om0 .om0b <- .om0b * control$diagOmegaBoundUpper .om0a <- RxODE::rxSymInvCholCreate(mat = .om0a, diag.xform = control$diagXform) .om0b <- RxODE::rxSymInvCholCreate(mat = .om0b, diag.xform = control$diagXform) .omdf <- data.frame(a = .om0a$theta, m = .ret$rxInv$theta, b = .om0b$theta, diag = .om0a$theta.diag) .omdf$lower <- with(.omdf, ifelse(a > b, b, a)) .omdf$lower <- with(.omdf, ifelse(lower == m, -Inf, lower)) .omdf$lower <- with(.omdf, ifelse(!diag, -Inf, lower)) .omdf$upper <- with(.omdf, ifelse(a < b, b, a)) .omdf$upper <- with(.omdf, ifelse(upper == m, Inf, upper)) .omdf$upper <- with(.omdf, ifelse(!diag, Inf, upper)) .ret$control$nomega <- length(.omdf$lower) .ret$control$neta <- sum(.omdf$diag) .ret$control$ntheta <- length(lower) .ret$control$nfixed <- sum(fixed) lower <- c(lower, .omdf$lower) upper <- c(upper, .omdf$upper) } else { .ret$control$nomega <- 0 .ret$control$neta <- 0 .ret$xType <- -1 .ret$control$ntheta <- length(lower) .ret$control$nfixed <- sum(fixed) } .ret$lower <- lower .ret$upper <- upper .ret$thetaIni <- inits$THTA .scaleC <- double(length(lower)) if (is.null(control$scaleC)) { .scaleC <- rep(NA_real_, length(lower)) } else { .scaleC <- as.double(control$scaleC) if (length(lower) > length(.scaleC)) { .scaleC <- c(.scaleC, rep(NA_real_, length(lower) - length(.scaleC))) } else if (length(lower) < length(.scaleC)) { .scaleC <- .scaleC[seq(1, length(lower))] warning("scaleC control option has more options than estimated population parameters, please check.") } } .ret$scaleC <- .scaleC if (exists("uif", envir = .ret)) { .ini <- as.data.frame(.ret$uif$ini)[!is.na(.ret$uif$ini$err), c("est", "err", "ntheta")] for (.i in seq_along(.ini$err)) { if (is.na(.ret$scaleC[.ini$ntheta[.i]])) { if (any(.ini$err[.i] == c("boxCox", "yeoJohnson", "pow2", "tbs", "tbsYj"))) { .ret$scaleC[.ini$ntheta[.i]] <- 1 } else if (any(.ini$err[.i] == c("prop", "add", "norm", "dnorm", "logn", "dlogn", "lnorm", "dlnorm"))) { .ret$scaleC[.ini$ntheta[.i]] <- 0.5 * abs(.ini$est[.i]) } } } for (.i in .ini$model$extraProps$powTheta) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- 1 } .ini <- as.data.frame(.ret$uif$ini) for (.i in .ini$model$extraProps$factorial) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- abs(1/digamma(.ini$est[.i] + 1)) } for (.i in .ini$model$extraProps$gamma) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- abs(1/digamma(.ini$est[.i])) } for (.i in .ini$model$extraProps$log) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- log(abs(.ini$est[.i])) * abs(.ini$est[.i]) } for (.i in .ret$logitThetas) { .b <- .ret$logitThetasLow[.i] .c <- .ret$logitThetasHi[.i] .a <- .ini$est[.i] if (is.na(.ret$scaleC[.i])) { .ret$scaleC[.i] <- 1 * (-.b + .c) * exp(-.a)/((1 + exp(-.a))^2 * (.b + 1 * (-.b + .c)/(1 + exp(-.a)))) } } } names(.ret$thetaIni) <- sprintf("THETA[%d]", seq_along(.ret$thetaIni)) if (is.null(etaMat) & !is.null(control$etaMat)) { .ret$etaMat <- control$etaMat } else { .ret$etaMat <- etaMat } .ret$setupTime <- (proc.time() - .pt)["elapsed"] if (exists("uif", envir = .ret)) { .tmp <- .ret$uif$logThetasList .ret$logThetas <- .tmp[[1]] .ret$logThetasF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasList .ret$logitThetas <- .tmp[[1]] .ret$logitThetasF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasListLow .ret$logitThetasLow <- .tmp[[1]] .ret$logitThetasLowF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasListHi .ret$logitThetasHi <- .tmp[[1]] .ret$logitThetasHiF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasList .ret$probitThetas <- .tmp[[1]] .ret$probitThetasF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasListLow .ret$probitThetasLow <- .tmp[[1]] .ret$probitThetasLowF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasListHi .ret$probitThetasHi <- .tmp[[1]] .ret$probitThetasHiF <- .tmp[[2]] } else { .ret$logThetasF <- integer(0) .ret$logitThetasF <- integer(0) .ret$logitThetasHiF <- numeric(0) .ret$logitThetasLowF <- numeric(0) .ret$logitThetas <- integer(0) .ret$logitThetasHi <- numeric(0) .ret$logitThetasLow <- numeric(0) .ret$probitThetasF <- integer(0) .ret$probitThetasHiF <- numeric(0) .ret$probitThetasLowF <- numeric(0) .ret$probitThetas <- integer(0) .ret$probitThetasHi <- numeric(0) .ret$probitThetasLow <- numeric(0) } if (exists("noLik", envir = .ret)) { if (!.ret$noLik) { .ret$.params <- c(sprintf("THETA[%d]", seq_along(.ret$thetaIni)), sprintf("ETA[%d]", seq(1, dim(.om0)[1]))) .ret$.thetan <- length(.ret$thetaIni) .ret$nobs <- sum(data$EVID == 0) } } .ret$control$printTop <- TRUE .ret$control$nF <- 0 .est0 <- .ret$thetaIni if (!is.null(.ret$model$pred.nolhs)) { .ret$control$predNeq <- length(.ret$model$pred.nolhs$state) } else { .ret$control$predNeq <- 0L } .fitFun <- function(.ret) { this.env <- environment() assign("err", "theta reset", this.env) while (this.env$err == "theta reset") { assign("err", "", this.env) .ret0 <- tryCatch({ foceiFitCpp_(.ret) }, error = function(e) { if (regexpr("theta reset", e$message) != -1) { assign("zeroOuter", FALSE, this.env) assign("zeroGrad", FALSE, this.env) if (regexpr("theta reset0", e$message) != -1) { assign("zeroGrad", TRUE, this.env) } else if (regexpr("theta resetZ", e$message) != -1) { assign("zeroOuter", TRUE, this.env) } assign("err", "theta reset", this.env) } else { assign("err", e$message, this.env) } }) if (this.env$err == "theta reset") { .nm <- names(.ret$thetaIni) .ret$thetaIni <- setNames(.thetaReset$thetaIni + 0, .nm) .ret$rxInv$theta <- .thetaReset$omegaTheta .ret$control$printTop <- FALSE .ret$etaMat <- .thetaReset$etaMat .ret$control$etaMat <- .thetaReset$etaMat .ret$control$maxInnerIterations <- .thetaReset$maxInnerIterations .ret$control$nF <- .thetaReset$nF .ret$control$gillRetC <- .thetaReset$gillRetC .ret$control$gillRet <- .thetaReset$gillRet .ret$control$gillRet <- .thetaReset$gillRet .ret$control$gillDf <- .thetaReset$gillDf .ret$control$gillDf2 <- .thetaReset$gillDf2 .ret$control$gillErr <- .thetaReset$gillErr .ret$control$rEps <- .thetaReset$rEps .ret$control$aEps <- .thetaReset$aEps .ret$control$rEpsC <- .thetaReset$rEpsC .ret$control$aEpsC <- .thetaReset$aEpsC .ret$control$c1 <- .thetaReset$c1 .ret$control$c2 <- .thetaReset$c2 if (this.env$zeroOuter) { message("Posthoc reset") .ret$control$maxOuterIterations <- 0L } else if (this.env$zeroGrad) { message("Theta reset (zero gradient values); Switch to bobyqa") RxODE::rxReq("minqa") .ret$control$outerOptFun <- .bobyqa .ret$control$outerOpt <- -1L } else { message("Theta reset (ETA drift)") } } } if (this.env$err != "") { stop(this.env$err) } else { return(.ret0) } } .ret0 <- try(.fitFun(.ret)) .n <- 1 while (inherits(.ret0, "try-error") && control$maxOuterIterations != 0 && .n <= control$nRetries) { message(sprintf("Restart %s", .n)) .ret$control$nF <- 0 .estNew <- .est0 + 0.2 * .n * abs(.est0) * stats::runif(length(.est0)) - 0.1 * .n .estNew <- sapply(seq_along(.est0), function(.i) { if (.ret$thetaFixed[.i]) { return(.est0[.i]) } else if (.estNew[.i] < lower[.i]) { return(lower + (.Machine$double.eps)^(1/7)) } else if (.estNew[.i] > upper[.i]) { return(upper - (.Machine$double.eps)^(1/7)) } else { return(.estNew[.i]) } }) .ret$thetaIni <- .estNew .ret0 <- try(.fitFun(.ret)) .n <- .n + 1 } if (inherits(.ret0, "try-error")) stop("Could not fit data.") .ret <- .ret0 if (exists("parHistData", .ret)) { .tmp <- .ret$parHistData .tmp <- .tmp[.tmp$type == "Unscaled", names(.tmp) != "type"] .iter <- .tmp$iter .tmp <- .tmp[, names(.tmp) != "iter"] .ret$parHistStacked <- data.frame(stack(.tmp), iter = .iter) names(.ret$parHistStacked) <- c("val", "par", "iter") .ret$parHist <- data.frame(iter = .iter, .tmp) } if (.mixed) { .etas <- .ret$ranef .thetas <- .ret$fixef .pars <- .Call(`_nlmixr_nlmixrParameters`, .thetas, .etas) .ret$shrink <- .Call(`_nlmixr_calcShrinkOnly`, .ret$omega, .pars$eta.lst, length(.etas$ID)) .updateParFixed(.ret) } else { .updateParFixed(.ret) } if (!exists("table", .ret)) { .ret$table <- tableControl() } if (control$calcTables) { .ret <- addTable(.ret, updateObject = "no", keep = keep, drop = drop, table = .ret$table) } .ret})(data = dat, inits = .FoceiInits, PKpars = .pars, model = .mod, pred = function() { return(nlmixr_pred) }, err = uif$error, lower = uif$focei.lower, upper = uif$focei.upper, fixed = uif$focei.fixed, thetaNames = uif$focei.names, etaNames = uif$eta.names, control = control, env = env, keep = .keep, drop = .drop): Not all the covariates are in the dataset.</span></div><div class='output co'>#> <span class='message'>Timing stopped at: 6.666 0.38 7.044</span></div><div class='input'><span class='va'>f_nlmixr_dfop_sfo_saem_obs</span> <span class='op'><-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr</a></span><span class='op'>(</span><span class='va'>f_mmkin_obs</span><span class='op'>[</span><span class='st'>"DFOP-SFO"</span>, <span class='op'>]</span>, est <span class='op'>=</span> <span class='st'>"saem"</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> parameter labels from comments are typically ignored in non-interactive mode</span></div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> Need to run with the source intact to parse comments</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'>→ generate SAEM model</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='error'>Error in configsaem(model = model, data = dat, inits = inits, mcmc = .mcmc, ODEopt = .ODEopt, seed = .seed, distribution = .dist, DEBUG = .DEBUG, addProp = .addProp, tol = .tol, itmax = .itmax, type = .type, powRange = .powRange, lambdaRange = .lambdaRange): covariate(s) not found: f_parent_to_A1</span></div><div class='output co'>#> <span class='message'>Timing stopped at: 1.39 0.093 1.483</span></div><div class='input'><span class='va'>f_nlmixr_dfop_sfo_focei_obs</span> <span class='op'><-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr</a></span><span class='op'>(</span><span class='va'>f_mmkin_obs</span><span class='op'>[</span><span class='st'>"DFOP-SFO"</span>, <span class='op'>]</span>, est <span class='op'>=</span> <span class='st'>"focei"</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> parameter labels from comments are typically ignored in non-interactive mode</span></div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> Need to run with the source intact to parse comments</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ calculate jacobian</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate sensitivities</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(f)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(R²)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling inner model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling EBE model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ compiling events FD model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>Model:</span></div><div class='output co'>#> <span class='message'>cmt(parent);</span>
#> <span class='message'>cmt(A1);</span>
#> <span class='message'>rx_expr_6~ETA[1]+THETA[1];</span>
#> <span class='message'>parent(0)=rx_expr_6;</span>
#> <span class='message'>rx_expr_7~ETA[4]+THETA[4];</span>
#> <span class='message'>rx_expr_8~ETA[6]+THETA[6];</span>
#> <span class='message'>rx_expr_9~ETA[5]+THETA[5];</span>
#> <span class='message'>rx_expr_12~exp(rx_expr_7);</span>
#> <span class='message'>rx_expr_13~exp(rx_expr_9);</span>
#> <span class='message'>rx_expr_15~t*rx_expr_12;</span>
#> <span class='message'>rx_expr_16~t*rx_expr_13;</span>
#> <span class='message'>rx_expr_17~exp(-(rx_expr_8));</span>
#> <span class='message'>rx_expr_19~1+rx_expr_17;</span>
#> <span class='message'>rx_expr_24~1/(rx_expr_19);</span>
#> <span class='message'>rx_expr_26~(rx_expr_24);</span>
#> <span class='message'>rx_expr_27~1-rx_expr_26;</span>
#> <span class='message'>d/dt(parent)=-parent*(exp(rx_expr_7-rx_expr_15)/(rx_expr_19)+exp(rx_expr_9-rx_expr_16)*(rx_expr_27))/(exp(-t*rx_expr_12)/(rx_expr_19)+exp(-t*rx_expr_13)*(rx_expr_27));</span>
#> <span class='message'>rx_expr_10~ETA[2]+THETA[2];</span>
#> <span class='message'>rx_expr_14~exp(rx_expr_10);</span>
#> <span class='message'>d/dt(A1)=-rx_expr_14*A1+parent*f_parent_to_A1*(exp(rx_expr_7-rx_expr_15)/(rx_expr_19)+exp(rx_expr_9-rx_expr_16)*(rx_expr_27))/(exp(-t*rx_expr_12)/(rx_expr_19)+exp(-t*rx_expr_13)*(rx_expr_27));</span>
#> <span class='message'>rx_expr_0~CMT==2;</span>
#> <span class='message'>rx_expr_1~CMT==1;</span>
#> <span class='message'>rx_expr_2~1-(rx_expr_0);</span>
#> <span class='message'>rx_yj_~2*(rx_expr_2)*(rx_expr_1)+2*(rx_expr_0);</span>
#> <span class='message'>rx_expr_3~(rx_expr_0);</span>
#> <span class='message'>rx_expr_5~(rx_expr_2);</span>
#> <span class='message'>rx_expr_18~rx_expr_5*(rx_expr_1);</span>
#> <span class='message'>rx_lambda_~rx_expr_18+rx_expr_3;</span>
#> <span class='message'>rx_hi_~rx_expr_18+rx_expr_3;</span>
#> <span class='message'>rx_low_~0;</span>
#> <span class='message'>rx_expr_4~A1*(rx_expr_0);</span>
#> <span class='message'>rx_expr_11~parent*(rx_expr_2);</span>
#> <span class='message'>rx_expr_22~rx_expr_11*(rx_expr_1);</span>
#> <span class='message'>rx_pred_=(rx_expr_4+rx_expr_22)*(rx_expr_0)+(rx_expr_4+rx_expr_22)*(rx_expr_2)*(rx_expr_1);</span>
#> <span class='message'>rx_r_=(rx_expr_0)*Rx_pow_di(THETA[8],2)+(rx_expr_2)*(rx_expr_1)*Rx_pow_di(THETA[7],2);</span>
#> <span class='message'>parent_0=THETA[1];</span>
#> <span class='message'>log_k_A1=THETA[2];</span>
#> <span class='message'>f_parent_qlogis=THETA[3];</span>
#> <span class='message'>log_k1=THETA[4];</span>
#> <span class='message'>log_k2=THETA[5];</span>
#> <span class='message'>g_qlogis=THETA[6];</span>
#> <span class='message'>sigma_parent=THETA[7];</span>
#> <span class='message'>sigma_A1=THETA[8];</span>
#> <span class='message'>eta.parent_0=ETA[1];</span>
#> <span class='message'>eta.log_k_A1=ETA[2];</span>
#> <span class='message'>eta.f_parent_qlogis=ETA[3];</span>
#> <span class='message'>eta.log_k1=ETA[4];</span>
#> <span class='message'>eta.log_k2=ETA[5];</span>
#> <span class='message'>eta.g_qlogis=ETA[6];</span>
#> <span class='message'>parent_0_model=rx_expr_6;</span>
#> <span class='message'>k_A1=rx_expr_14;</span>
#> <span class='message'>k1=rx_expr_12;</span>
#> <span class='message'>k2=rx_expr_13;</span>
#> <span class='message'>f_parent=1/(1+exp(-(ETA[3]+THETA[3])));</span>
#> <span class='message'>g=1/(rx_expr_19);</span>
#> <span class='message'>tad=tad();</span>
#> <span class='message'>dosenum=dosenum();</span></div><div class='output co'>#> <span class='message'>Needed Covariates:</span></div><div class='output co'>#> <span class='message'>[1] "f_parent_to_A1" "CMT" </span></div><div class='output co'>#> <span class='error'>Error in (function (data, inits, PKpars, model = NULL, pred = NULL, err = NULL, lower = -Inf, upper = Inf, fixed = NULL, skipCov = NULL, control = foceiControl(), thetaNames = NULL, etaNames = NULL, etaMat = NULL, ..., env = NULL, keep = NULL, drop = NULL) { set.seed(control$seed) .pt <- proc.time() RxODE::.setWarnIdSort(FALSE) on.exit(RxODE::.setWarnIdSort(TRUE)) loadNamespace("n1qn1") if (!RxODE::rxIs(control, "foceiControl")) { control <- do.call(foceiControl, control) } if (is.null(env)) { .ret <- new.env(parent = emptyenv()) } else { .ret <- env } .ret$origData <- data .ret$etaNames <- etaNames .ret$thetaFixed <- fixed .ret$control <- control .ret$control$focei.mu.ref <- integer(0) if (is(model, "RxODE") || is(model, "character")) { .ret$ODEmodel <- TRUE if (class(pred) != "function") { stop("pred must be a function specifying the prediction variables in this model.") } } else { .ret$ODEmodel <- TRUE model <- RxODE::rxGetLin(PKpars) pred <- eval(parse(text = "function(){return(Central);}")) } .square <- function(x) x * x .ret$diagXformInv <- c(sqrt = ".square", log = "exp", identity = "identity")[control$diagXform] if (is.null(err)) { err <- eval(parse(text = paste0("function(){err", paste(inits$ERROR[[1]], collapse = ""), "}"))) } .covNames <- .parNames <- c() .ret$adjLik <- control$adjLik .mixed <- !is.null(inits$OMGA) && length(inits$OMGA) > 0 if (!exists("noLik", envir = .ret)) { .atol <- rep(control$atol, length(RxODE::rxModelVars(model)$state)) .rtol <- rep(control$rtol, length(RxODE::rxModelVars(model)$state)) .ssAtol <- rep(control$ssAtol, length(RxODE::rxModelVars(model)$state)) .ssRtol <- rep(control$ssRtol, length(RxODE::rxModelVars(model)$state)) .ret$model <- RxODE::rxSymPySetupPred(model, pred, PKpars, err, grad = (control$derivMethod == 2L), pred.minus.dv = TRUE, sum.prod = control$sumProd, theta.derivs = FALSE, optExpression = control$optExpression, interaction = (control$interaction == 1L), only.numeric = !.mixed, run.internal = TRUE, addProp = control$addProp) if (!is.null(.ret$model$inner)) { .atol <- c(.atol, rep(control$atolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.atol))) .rtol <- c(.rtol, rep(control$rtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.rtol))) .ret$control$rxControl$atol <- .atol .ret$control$rxControl$rtol <- .rtol .ssAtol <- c(.ssAtol, rep(control$ssAtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.ssAtol))) .ssRtol <- c(.ssRtol, rep(control$ssRtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.ssRtol))) .ret$control$rxControl$ssAtol <- .ssAtol .ret$control$rxControl$ssRtol <- .ssRtol } .covNames <- .parNames <- RxODE::rxParams(.ret$model$pred.only) .covNames <- .covNames[regexpr(rex::rex(start, or("THETA", "ETA"), "[", numbers, "]", end), .covNames) == -1] colnames(data) <- sapply(names(data), function(x) { if (any(x == .covNames)) { return(x) } else { return(toupper(x)) } }) .lhs <- c(names(RxODE::rxInits(.ret$model$pred.only)), RxODE::rxLhs(.ret$model$pred.only)) if (length(.lhs) > 0) { .covNames <- .covNames[regexpr(rex::rex(start, or(.lhs), end), .covNames) == -1] } if (length(.covNames) > 0) { if (!all(.covNames %in% names(data))) { message("Model:") RxODE::rxCat(.ret$model$pred.only) message("Needed Covariates:") nlmixrPrint(.covNames) stop("Not all the covariates are in the dataset.") } message("Needed Covariates:") print(.covNames) } .extraPars <- .ret$model$extra.pars } else { if (.ret$noLik) { .atol <- rep(control$atol, length(RxODE::rxModelVars(model)$state)) .rtol <- rep(control$rtol, length(RxODE::rxModelVars(model)$state)) .ret$model <- RxODE::rxSymPySetupPred(model, pred, PKpars, err, grad = FALSE, pred.minus.dv = TRUE, sum.prod = control$sumProd, theta.derivs = FALSE, optExpression = control$optExpression, run.internal = TRUE, only.numeric = TRUE, addProp = control$addProp) if (!is.null(.ret$model$inner)) { .atol <- c(.atol, rep(control$atolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.atol))) .rtol <- c(.rtol, rep(control$rtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.rtol))) .ret$control$rxControl$atol <- .atol .ret$control$rxControl$rtol <- .rtol } .covNames <- .parNames <- RxODE::rxParams(.ret$model$pred.only) .covNames <- .covNames[regexpr(rex::rex(start, or("THETA", "ETA"), "[", numbers, "]", end), .covNames) == -1] colnames(data) <- sapply(names(data), function(x) { if (any(x == .covNames)) { return(x) } else { return(toupper(x)) } }) .lhs <- c(names(RxODE::rxInits(.ret$model$pred.only)), RxODE::rxLhs(.ret$model$pred.only)) if (length(.lhs) > 0) { .covNames <- .covNames[regexpr(rex::rex(start, or(.lhs), end), .covNames) == -1] } if (length(.covNames) > 0) { if (!all(.covNames %in% names(data))) { message("Model:") RxODE::rxCat(.ret$model$pred.only) message("Needed Covariates:") nlmixrPrint(.covNames) stop("Not all the covariates are in the dataset.") } message("Needed Covariates:") print(.covNames) } .extraPars <- .ret$model$extra.pars } else { .extraPars <- NULL } } .ret$skipCov <- skipCov if (is.null(skipCov)) { if (is.null(fixed)) { .tmp <- rep(FALSE, length(inits$THTA)) } else { if (length(fixed) < length(inits$THTA)) { .tmp <- c(fixed, rep(FALSE, length(inits$THTA) - length(fixed))) } else { .tmp <- fixed[1:length(inits$THTA)] } } if (exists("uif", envir = .ret)) { .uifErr <- .ret$uif$ini$err[!is.na(.ret$uif$ini$ntheta)] .uifErr <- sapply(.uifErr, function(x) { if (is.na(x)) { return(FALSE) } return(!any(x == c("pow2", "tbs", "tbsYj"))) }) .tmp <- (.tmp | .uifErr) } .ret$skipCov <- c(.tmp, rep(TRUE, length(.extraPars))) .ret$control$focei.mu.ref <- .ret$uif$focei.mu.ref } if (is.null(.extraPars)) { .nms <- c(sprintf("THETA[%s]", seq_along(inits$THTA))) } else { .nms <- c(sprintf("THETA[%s]", seq_along(inits$THTA)), sprintf("ERR[%s]", seq_along(.extraPars))) } if (!is.null(thetaNames) && (length(inits$THTA) + length(.extraPars)) == length(thetaNames)) { .nms <- thetaNames } .ret$thetaNames <- .nms .thetaReset$thetaNames <- .nms if (length(lower) == 1) { lower <- rep(lower, length(inits$THTA)) } else if (length(lower) != length(inits$THTA)) { print(inits$THTA) print(lower) stop("Lower must be a single constant for all the THETA lower bounds, or match the dimension of THETA.") } if (length(upper) == 1) { upper <- rep(upper, length(inits$THTA)) } else if (length(lower) != length(inits$THTA)) { stop("Upper must be a single constant for all the THETA lower bounds, or match the dimension of THETA.") } if (!is.null(.extraPars)) { .ret$model$extra.pars <- eval(call(control$diagXform, .ret$model$extra.pars)) if (length(.ret$model$extra.pars) > 0) { inits$THTA <- c(inits$THTA, .ret$model$extra.pars) .lowerErr <- rep(control$atol[1] * 10, length(.ret$model$extra.pars)) .upperErr <- rep(Inf, length(.ret$model$extra.pars)) lower <- c(lower, .lowerErr) upper <- c(upper, .upperErr) } } if (is.null(data$ID)) stop("\"ID\" not found in data") if (is.null(data$DV)) stop("\"DV\" not found in data") if (is.null(data$EVID)) data$EVID <- 0 if (is.null(data$AMT)) data$AMT <- 0 for (.v in c("TIME", "AMT", "DV", .covNames)) { data[[.v]] <- as.double(data[[.v]]) } .ret$dataSav <- data .ds <- data[data$EVID != 0 & data$EVID != 2, c("ID", "TIME", "AMT", "EVID", .covNames)] .w <- which(tolower(names(data)) == "limit") .limitName <- NULL if (length(.w) == 1L) { .limitName <- names(data)[.w] } .censName <- NULL .w <- which(tolower(names(data)) == "cens") if (length(.w) == 1L) { .censName <- names(data[.w]) } data <- data[data$EVID == 0 | data$EVID == 2, c("ID", "TIME", "DV", "EVID", .covNames, .limitName, .censName)] .w <- which(!(names(.ret$dataSav) %in% c(.covNames, keep))) names(.ret$dataSav)[.w] <- tolower(names(.ret$dataSav[.w])) if (.mixed) { .lh <- .parseOM(inits$OMGA) .nlh <- sapply(.lh, length) .osplt <- rep(1:length(.lh), .nlh) .lini <- list(inits$THTA, unlist(.lh)) .nlini <- sapply(.lini, length) .nsplt <- rep(1:length(.lini), .nlini) .om0 <- .genOM(.lh) if (length(etaNames) == dim(.om0)[1]) { .ret$etaNames <- .ret$etaNames } else { .ret$etaNames <- sprintf("ETA[%d]", seq(1, dim(.om0)[1])) } .ret$rxInv <- RxODE::rxSymInvCholCreate(mat = .om0, diag.xform = control$diagXform) .ret$xType <- .ret$rxInv$xType .om0a <- .om0 .om0a <- .om0a/control$diagOmegaBoundLower .om0b <- .om0 .om0b <- .om0b * control$diagOmegaBoundUpper .om0a <- RxODE::rxSymInvCholCreate(mat = .om0a, diag.xform = control$diagXform) .om0b <- RxODE::rxSymInvCholCreate(mat = .om0b, diag.xform = control$diagXform) .omdf <- data.frame(a = .om0a$theta, m = .ret$rxInv$theta, b = .om0b$theta, diag = .om0a$theta.diag) .omdf$lower <- with(.omdf, ifelse(a > b, b, a)) .omdf$lower <- with(.omdf, ifelse(lower == m, -Inf, lower)) .omdf$lower <- with(.omdf, ifelse(!diag, -Inf, lower)) .omdf$upper <- with(.omdf, ifelse(a < b, b, a)) .omdf$upper <- with(.omdf, ifelse(upper == m, Inf, upper)) .omdf$upper <- with(.omdf, ifelse(!diag, Inf, upper)) .ret$control$nomega <- length(.omdf$lower) .ret$control$neta <- sum(.omdf$diag) .ret$control$ntheta <- length(lower) .ret$control$nfixed <- sum(fixed) lower <- c(lower, .omdf$lower) upper <- c(upper, .omdf$upper) } else { .ret$control$nomega <- 0 .ret$control$neta <- 0 .ret$xType <- -1 .ret$control$ntheta <- length(lower) .ret$control$nfixed <- sum(fixed) } .ret$lower <- lower .ret$upper <- upper .ret$thetaIni <- inits$THTA .scaleC <- double(length(lower)) if (is.null(control$scaleC)) { .scaleC <- rep(NA_real_, length(lower)) } else { .scaleC <- as.double(control$scaleC) if (length(lower) > length(.scaleC)) { .scaleC <- c(.scaleC, rep(NA_real_, length(lower) - length(.scaleC))) } else if (length(lower) < length(.scaleC)) { .scaleC <- .scaleC[seq(1, length(lower))] warning("scaleC control option has more options than estimated population parameters, please check.") } } .ret$scaleC <- .scaleC if (exists("uif", envir = .ret)) { .ini <- as.data.frame(.ret$uif$ini)[!is.na(.ret$uif$ini$err), c("est", "err", "ntheta")] for (.i in seq_along(.ini$err)) { if (is.na(.ret$scaleC[.ini$ntheta[.i]])) { if (any(.ini$err[.i] == c("boxCox", "yeoJohnson", "pow2", "tbs", "tbsYj"))) { .ret$scaleC[.ini$ntheta[.i]] <- 1 } else if (any(.ini$err[.i] == c("prop", "add", "norm", "dnorm", "logn", "dlogn", "lnorm", "dlnorm"))) { .ret$scaleC[.ini$ntheta[.i]] <- 0.5 * abs(.ini$est[.i]) } } } for (.i in .ini$model$extraProps$powTheta) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- 1 } .ini <- as.data.frame(.ret$uif$ini) for (.i in .ini$model$extraProps$factorial) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- abs(1/digamma(.ini$est[.i] + 1)) } for (.i in .ini$model$extraProps$gamma) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- abs(1/digamma(.ini$est[.i])) } for (.i in .ini$model$extraProps$log) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- log(abs(.ini$est[.i])) * abs(.ini$est[.i]) } for (.i in .ret$logitThetas) { .b <- .ret$logitThetasLow[.i] .c <- .ret$logitThetasHi[.i] .a <- .ini$est[.i] if (is.na(.ret$scaleC[.i])) { .ret$scaleC[.i] <- 1 * (-.b + .c) * exp(-.a)/((1 + exp(-.a))^2 * (.b + 1 * (-.b + .c)/(1 + exp(-.a)))) } } } names(.ret$thetaIni) <- sprintf("THETA[%d]", seq_along(.ret$thetaIni)) if (is.null(etaMat) & !is.null(control$etaMat)) { .ret$etaMat <- control$etaMat } else { .ret$etaMat <- etaMat } .ret$setupTime <- (proc.time() - .pt)["elapsed"] if (exists("uif", envir = .ret)) { .tmp <- .ret$uif$logThetasList .ret$logThetas <- .tmp[[1]] .ret$logThetasF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasList .ret$logitThetas <- .tmp[[1]] .ret$logitThetasF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasListLow .ret$logitThetasLow <- .tmp[[1]] .ret$logitThetasLowF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasListHi .ret$logitThetasHi <- .tmp[[1]] .ret$logitThetasHiF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasList .ret$probitThetas <- .tmp[[1]] .ret$probitThetasF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasListLow .ret$probitThetasLow <- .tmp[[1]] .ret$probitThetasLowF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasListHi .ret$probitThetasHi <- .tmp[[1]] .ret$probitThetasHiF <- .tmp[[2]] } else { .ret$logThetasF <- integer(0) .ret$logitThetasF <- integer(0) .ret$logitThetasHiF <- numeric(0) .ret$logitThetasLowF <- numeric(0) .ret$logitThetas <- integer(0) .ret$logitThetasHi <- numeric(0) .ret$logitThetasLow <- numeric(0) .ret$probitThetasF <- integer(0) .ret$probitThetasHiF <- numeric(0) .ret$probitThetasLowF <- numeric(0) .ret$probitThetas <- integer(0) .ret$probitThetasHi <- numeric(0) .ret$probitThetasLow <- numeric(0) } if (exists("noLik", envir = .ret)) { if (!.ret$noLik) { .ret$.params <- c(sprintf("THETA[%d]", seq_along(.ret$thetaIni)), sprintf("ETA[%d]", seq(1, dim(.om0)[1]))) .ret$.thetan <- length(.ret$thetaIni) .ret$nobs <- sum(data$EVID == 0) } } .ret$control$printTop <- TRUE .ret$control$nF <- 0 .est0 <- .ret$thetaIni if (!is.null(.ret$model$pred.nolhs)) { .ret$control$predNeq <- length(.ret$model$pred.nolhs$state) } else { .ret$control$predNeq <- 0L } .fitFun <- function(.ret) { this.env <- environment() assign("err", "theta reset", this.env) while (this.env$err == "theta reset") { assign("err", "", this.env) .ret0 <- tryCatch({ foceiFitCpp_(.ret) }, error = function(e) { if (regexpr("theta reset", e$message) != -1) { assign("zeroOuter", FALSE, this.env) assign("zeroGrad", FALSE, this.env) if (regexpr("theta reset0", e$message) != -1) { assign("zeroGrad", TRUE, this.env) } else if (regexpr("theta resetZ", e$message) != -1) { assign("zeroOuter", TRUE, this.env) } assign("err", "theta reset", this.env) } else { assign("err", e$message, this.env) } }) if (this.env$err == "theta reset") { .nm <- names(.ret$thetaIni) .ret$thetaIni <- setNames(.thetaReset$thetaIni + 0, .nm) .ret$rxInv$theta <- .thetaReset$omegaTheta .ret$control$printTop <- FALSE .ret$etaMat <- .thetaReset$etaMat .ret$control$etaMat <- .thetaReset$etaMat .ret$control$maxInnerIterations <- .thetaReset$maxInnerIterations .ret$control$nF <- .thetaReset$nF .ret$control$gillRetC <- .thetaReset$gillRetC .ret$control$gillRet <- .thetaReset$gillRet .ret$control$gillRet <- .thetaReset$gillRet .ret$control$gillDf <- .thetaReset$gillDf .ret$control$gillDf2 <- .thetaReset$gillDf2 .ret$control$gillErr <- .thetaReset$gillErr .ret$control$rEps <- .thetaReset$rEps .ret$control$aEps <- .thetaReset$aEps .ret$control$rEpsC <- .thetaReset$rEpsC .ret$control$aEpsC <- .thetaReset$aEpsC .ret$control$c1 <- .thetaReset$c1 .ret$control$c2 <- .thetaReset$c2 if (this.env$zeroOuter) { message("Posthoc reset") .ret$control$maxOuterIterations <- 0L } else if (this.env$zeroGrad) { message("Theta reset (zero gradient values); Switch to bobyqa") RxODE::rxReq("minqa") .ret$control$outerOptFun <- .bobyqa .ret$control$outerOpt <- -1L } else { message("Theta reset (ETA drift)") } } } if (this.env$err != "") { stop(this.env$err) } else { return(.ret0) } } .ret0 <- try(.fitFun(.ret)) .n <- 1 while (inherits(.ret0, "try-error") && control$maxOuterIterations != 0 && .n <= control$nRetries) { message(sprintf("Restart %s", .n)) .ret$control$nF <- 0 .estNew <- .est0 + 0.2 * .n * abs(.est0) * stats::runif(length(.est0)) - 0.1 * .n .estNew <- sapply(seq_along(.est0), function(.i) { if (.ret$thetaFixed[.i]) { return(.est0[.i]) } else if (.estNew[.i] < lower[.i]) { return(lower + (.Machine$double.eps)^(1/7)) } else if (.estNew[.i] > upper[.i]) { return(upper - (.Machine$double.eps)^(1/7)) } else { return(.estNew[.i]) } }) .ret$thetaIni <- .estNew .ret0 <- try(.fitFun(.ret)) .n <- .n + 1 } if (inherits(.ret0, "try-error")) stop("Could not fit data.") .ret <- .ret0 if (exists("parHistData", .ret)) { .tmp <- .ret$parHistData .tmp <- .tmp[.tmp$type == "Unscaled", names(.tmp) != "type"] .iter <- .tmp$iter .tmp <- .tmp[, names(.tmp) != "iter"] .ret$parHistStacked <- data.frame(stack(.tmp), iter = .iter) names(.ret$parHistStacked) <- c("val", "par", "iter") .ret$parHist <- data.frame(iter = .iter, .tmp) } if (.mixed) { .etas <- .ret$ranef .thetas <- .ret$fixef .pars <- .Call(`_nlmixr_nlmixrParameters`, .thetas, .etas) .ret$shrink <- .Call(`_nlmixr_calcShrinkOnly`, .ret$omega, .pars$eta.lst, length(.etas$ID)) .updateParFixed(.ret) } else { .updateParFixed(.ret) } if (!exists("table", .ret)) { .ret$table <- tableControl() } if (control$calcTables) { .ret <- addTable(.ret, updateObject = "no", keep = keep, drop = drop, table = .ret$table) } .ret})(data = dat, inits = .FoceiInits, PKpars = .pars, model = .mod, pred = function() { return(nlmixr_pred) }, err = uif$error, lower = uif$focei.lower, upper = uif$focei.upper, fixed = uif$focei.fixed, thetaNames = uif$focei.names, etaNames = uif$eta.names, control = control, env = env, keep = .keep, drop = .drop): Not all the covariates are in the dataset.</span></div><div class='output co'>#> <span class='message'>Timing stopped at: 14.67 0.529 15.2</span></div><div class='input'>
<span class='co'># Identical two-component error for all variables is only possible with</span>
<span class='co'># est = 'focei' in nlmixr</span>
<span class='va'>f_nlmixr_fomc_sfo_focei_tc</span> <span class='op'><-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr</a></span><span class='op'>(</span><span class='va'>f_mmkin_tc</span><span class='op'>[</span><span class='st'>"FOMC-SFO"</span>, <span class='op'>]</span>, est <span class='op'>=</span> <span class='st'>"focei"</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> parameter labels from comments are typically ignored in non-interactive mode</span></div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> Need to run with the source intact to parse comments</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ calculate jacobian</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate sensitivities</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(f)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(R²)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling inner model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling EBE model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ compiling events FD model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>Model:</span></div><div class='output co'>#> <span class='message'>cmt(parent);</span>
#> <span class='message'>cmt(A1);</span>
#> <span class='message'>rx_expr_6~ETA[1]+THETA[1];</span>
#> <span class='message'>parent(0)=rx_expr_6;</span>
#> <span class='message'>rx_expr_7~ETA[4]+THETA[4];</span>
#> <span class='message'>rx_expr_8~ETA[5]+THETA[5];</span>
#> <span class='message'>rx_expr_14~exp(-(rx_expr_8));</span>
#> <span class='message'>rx_expr_16~t*rx_expr_14;</span>
#> <span class='message'>rx_expr_17~1+rx_expr_16;</span>
#> <span class='message'>rx_expr_19~rx_expr_7-(rx_expr_8);</span>
#> <span class='message'>rx_expr_21~exp(rx_expr_19);</span>
#> <span class='message'>d/dt(parent)=-rx_expr_21*parent/(rx_expr_17);</span>
#> <span class='message'>rx_expr_9~ETA[2]+THETA[2];</span>
#> <span class='message'>rx_expr_11~exp(rx_expr_9);</span>
#> <span class='message'>d/dt(A1)=-rx_expr_11*A1+rx_expr_21*parent*f_parent_to_A1/(rx_expr_17);</span>
#> <span class='message'>rx_expr_0~CMT==2;</span>
#> <span class='message'>rx_expr_1~CMT==1;</span>
#> <span class='message'>rx_expr_2~1-(rx_expr_0);</span>
#> <span class='message'>rx_yj_~2*(rx_expr_2)*(rx_expr_1)+2*(rx_expr_0);</span>
#> <span class='message'>rx_expr_3~(rx_expr_0);</span>
#> <span class='message'>rx_expr_5~(rx_expr_2);</span>
#> <span class='message'>rx_expr_15~rx_expr_5*(rx_expr_1);</span>
#> <span class='message'>rx_lambda_~rx_expr_15+rx_expr_3;</span>
#> <span class='message'>rx_hi_~rx_expr_15+rx_expr_3;</span>
#> <span class='message'>rx_low_~0;</span>
#> <span class='message'>rx_expr_4~A1*(rx_expr_0);</span>
#> <span class='message'>rx_expr_10~parent*(rx_expr_2);</span>
#> <span class='message'>rx_expr_18~rx_expr_10*(rx_expr_1);</span>
#> <span class='message'>rx_pred_=(rx_expr_4+rx_expr_18)*(rx_expr_0)+(rx_expr_4+rx_expr_18)*(rx_expr_2)*(rx_expr_1);</span>
#> <span class='message'>rx_expr_12~Rx_pow_di(THETA[7],2);</span>
#> <span class='message'>rx_expr_13~Rx_pow_di(THETA[6],2);</span>
#> <span class='message'>rx_r_=(Rx_pow_di(((rx_expr_4+rx_expr_18)*(rx_expr_0)+(rx_expr_4+rx_expr_18)*(rx_expr_2)*(rx_expr_1)),2)*rx_expr_12+rx_expr_13)*(rx_expr_0)+(rx_expr_12*Rx_pow_di(((rx_expr_4+rx_expr_18)*(rx_expr_1)),2)+rx_expr_13)*(rx_expr_2)*(rx_expr_1);</span>
#> <span class='message'>parent_0=THETA[1];</span>
#> <span class='message'>log_k_A1=THETA[2];</span>
#> <span class='message'>f_parent_qlogis=THETA[3];</span>
#> <span class='message'>log_alpha=THETA[4];</span>
#> <span class='message'>log_beta=THETA[5];</span>
#> <span class='message'>sigma_low=THETA[6];</span>
#> <span class='message'>rsd_high=THETA[7];</span>
#> <span class='message'>eta.parent_0=ETA[1];</span>
#> <span class='message'>eta.log_k_A1=ETA[2];</span>
#> <span class='message'>eta.f_parent_qlogis=ETA[3];</span>
#> <span class='message'>eta.log_alpha=ETA[4];</span>
#> <span class='message'>eta.log_beta=ETA[5];</span>
#> <span class='message'>parent_0_model=rx_expr_6;</span>
#> <span class='message'>k_A1=rx_expr_11;</span>
#> <span class='message'>alpha=exp(rx_expr_7);</span>
#> <span class='message'>beta=exp(rx_expr_8);</span>
#> <span class='message'>f_parent=1/(1+exp(-(ETA[3]+THETA[3])));</span>
#> <span class='message'>tad=tad();</span>
#> <span class='message'>dosenum=dosenum();</span></div><div class='output co'>#> <span class='message'>Needed Covariates:</span></div><div class='output co'>#> <span class='message'>[1] "f_parent_to_A1" "CMT" </span></div><div class='output co'>#> <span class='error'>Error in (function (data, inits, PKpars, model = NULL, pred = NULL, err = NULL, lower = -Inf, upper = Inf, fixed = NULL, skipCov = NULL, control = foceiControl(), thetaNames = NULL, etaNames = NULL, etaMat = NULL, ..., env = NULL, keep = NULL, drop = NULL) { set.seed(control$seed) .pt <- proc.time() RxODE::.setWarnIdSort(FALSE) on.exit(RxODE::.setWarnIdSort(TRUE)) loadNamespace("n1qn1") if (!RxODE::rxIs(control, "foceiControl")) { control <- do.call(foceiControl, control) } if (is.null(env)) { .ret <- new.env(parent = emptyenv()) } else { .ret <- env } .ret$origData <- data .ret$etaNames <- etaNames .ret$thetaFixed <- fixed .ret$control <- control .ret$control$focei.mu.ref <- integer(0) if (is(model, "RxODE") || is(model, "character")) { .ret$ODEmodel <- TRUE if (class(pred) != "function") { stop("pred must be a function specifying the prediction variables in this model.") } } else { .ret$ODEmodel <- TRUE model <- RxODE::rxGetLin(PKpars) pred <- eval(parse(text = "function(){return(Central);}")) } .square <- function(x) x * x .ret$diagXformInv <- c(sqrt = ".square", log = "exp", identity = "identity")[control$diagXform] if (is.null(err)) { err <- eval(parse(text = paste0("function(){err", paste(inits$ERROR[[1]], collapse = ""), "}"))) } .covNames <- .parNames <- c() .ret$adjLik <- control$adjLik .mixed <- !is.null(inits$OMGA) && length(inits$OMGA) > 0 if (!exists("noLik", envir = .ret)) { .atol <- rep(control$atol, length(RxODE::rxModelVars(model)$state)) .rtol <- rep(control$rtol, length(RxODE::rxModelVars(model)$state)) .ssAtol <- rep(control$ssAtol, length(RxODE::rxModelVars(model)$state)) .ssRtol <- rep(control$ssRtol, length(RxODE::rxModelVars(model)$state)) .ret$model <- RxODE::rxSymPySetupPred(model, pred, PKpars, err, grad = (control$derivMethod == 2L), pred.minus.dv = TRUE, sum.prod = control$sumProd, theta.derivs = FALSE, optExpression = control$optExpression, interaction = (control$interaction == 1L), only.numeric = !.mixed, run.internal = TRUE, addProp = control$addProp) if (!is.null(.ret$model$inner)) { .atol <- c(.atol, rep(control$atolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.atol))) .rtol <- c(.rtol, rep(control$rtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.rtol))) .ret$control$rxControl$atol <- .atol .ret$control$rxControl$rtol <- .rtol .ssAtol <- c(.ssAtol, rep(control$ssAtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.ssAtol))) .ssRtol <- c(.ssRtol, rep(control$ssRtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.ssRtol))) .ret$control$rxControl$ssAtol <- .ssAtol .ret$control$rxControl$ssRtol <- .ssRtol } .covNames <- .parNames <- RxODE::rxParams(.ret$model$pred.only) .covNames <- .covNames[regexpr(rex::rex(start, or("THETA", "ETA"), "[", numbers, "]", end), .covNames) == -1] colnames(data) <- sapply(names(data), function(x) { if (any(x == .covNames)) { return(x) } else { return(toupper(x)) } }) .lhs <- c(names(RxODE::rxInits(.ret$model$pred.only)), RxODE::rxLhs(.ret$model$pred.only)) if (length(.lhs) > 0) { .covNames <- .covNames[regexpr(rex::rex(start, or(.lhs), end), .covNames) == -1] } if (length(.covNames) > 0) { if (!all(.covNames %in% names(data))) { message("Model:") RxODE::rxCat(.ret$model$pred.only) message("Needed Covariates:") nlmixrPrint(.covNames) stop("Not all the covariates are in the dataset.") } message("Needed Covariates:") print(.covNames) } .extraPars <- .ret$model$extra.pars } else { if (.ret$noLik) { .atol <- rep(control$atol, length(RxODE::rxModelVars(model)$state)) .rtol <- rep(control$rtol, length(RxODE::rxModelVars(model)$state)) .ret$model <- RxODE::rxSymPySetupPred(model, pred, PKpars, err, grad = FALSE, pred.minus.dv = TRUE, sum.prod = control$sumProd, theta.derivs = FALSE, optExpression = control$optExpression, run.internal = TRUE, only.numeric = TRUE, addProp = control$addProp) if (!is.null(.ret$model$inner)) { .atol <- c(.atol, rep(control$atolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.atol))) .rtol <- c(.rtol, rep(control$rtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.rtol))) .ret$control$rxControl$atol <- .atol .ret$control$rxControl$rtol <- .rtol } .covNames <- .parNames <- RxODE::rxParams(.ret$model$pred.only) .covNames <- .covNames[regexpr(rex::rex(start, or("THETA", "ETA"), "[", numbers, "]", end), .covNames) == -1] colnames(data) <- sapply(names(data), function(x) { if (any(x == .covNames)) { return(x) } else { return(toupper(x)) } }) .lhs <- c(names(RxODE::rxInits(.ret$model$pred.only)), RxODE::rxLhs(.ret$model$pred.only)) if (length(.lhs) > 0) { .covNames <- .covNames[regexpr(rex::rex(start, or(.lhs), end), .covNames) == -1] } if (length(.covNames) > 0) { if (!all(.covNames %in% names(data))) { message("Model:") RxODE::rxCat(.ret$model$pred.only) message("Needed Covariates:") nlmixrPrint(.covNames) stop("Not all the covariates are in the dataset.") } message("Needed Covariates:") print(.covNames) } .extraPars <- .ret$model$extra.pars } else { .extraPars <- NULL } } .ret$skipCov <- skipCov if (is.null(skipCov)) { if (is.null(fixed)) { .tmp <- rep(FALSE, length(inits$THTA)) } else { if (length(fixed) < length(inits$THTA)) { .tmp <- c(fixed, rep(FALSE, length(inits$THTA) - length(fixed))) } else { .tmp <- fixed[1:length(inits$THTA)] } } if (exists("uif", envir = .ret)) { .uifErr <- .ret$uif$ini$err[!is.na(.ret$uif$ini$ntheta)] .uifErr <- sapply(.uifErr, function(x) { if (is.na(x)) { return(FALSE) } return(!any(x == c("pow2", "tbs", "tbsYj"))) }) .tmp <- (.tmp | .uifErr) } .ret$skipCov <- c(.tmp, rep(TRUE, length(.extraPars))) .ret$control$focei.mu.ref <- .ret$uif$focei.mu.ref } if (is.null(.extraPars)) { .nms <- c(sprintf("THETA[%s]", seq_along(inits$THTA))) } else { .nms <- c(sprintf("THETA[%s]", seq_along(inits$THTA)), sprintf("ERR[%s]", seq_along(.extraPars))) } if (!is.null(thetaNames) && (length(inits$THTA) + length(.extraPars)) == length(thetaNames)) { .nms <- thetaNames } .ret$thetaNames <- .nms .thetaReset$thetaNames <- .nms if (length(lower) == 1) { lower <- rep(lower, length(inits$THTA)) } else if (length(lower) != length(inits$THTA)) { print(inits$THTA) print(lower) stop("Lower must be a single constant for all the THETA lower bounds, or match the dimension of THETA.") } if (length(upper) == 1) { upper <- rep(upper, length(inits$THTA)) } else if (length(lower) != length(inits$THTA)) { stop("Upper must be a single constant for all the THETA lower bounds, or match the dimension of THETA.") } if (!is.null(.extraPars)) { .ret$model$extra.pars <- eval(call(control$diagXform, .ret$model$extra.pars)) if (length(.ret$model$extra.pars) > 0) { inits$THTA <- c(inits$THTA, .ret$model$extra.pars) .lowerErr <- rep(control$atol[1] * 10, length(.ret$model$extra.pars)) .upperErr <- rep(Inf, length(.ret$model$extra.pars)) lower <- c(lower, .lowerErr) upper <- c(upper, .upperErr) } } if (is.null(data$ID)) stop("\"ID\" not found in data") if (is.null(data$DV)) stop("\"DV\" not found in data") if (is.null(data$EVID)) data$EVID <- 0 if (is.null(data$AMT)) data$AMT <- 0 for (.v in c("TIME", "AMT", "DV", .covNames)) { data[[.v]] <- as.double(data[[.v]]) } .ret$dataSav <- data .ds <- data[data$EVID != 0 & data$EVID != 2, c("ID", "TIME", "AMT", "EVID", .covNames)] .w <- which(tolower(names(data)) == "limit") .limitName <- NULL if (length(.w) == 1L) { .limitName <- names(data)[.w] } .censName <- NULL .w <- which(tolower(names(data)) == "cens") if (length(.w) == 1L) { .censName <- names(data[.w]) } data <- data[data$EVID == 0 | data$EVID == 2, c("ID", "TIME", "DV", "EVID", .covNames, .limitName, .censName)] .w <- which(!(names(.ret$dataSav) %in% c(.covNames, keep))) names(.ret$dataSav)[.w] <- tolower(names(.ret$dataSav[.w])) if (.mixed) { .lh <- .parseOM(inits$OMGA) .nlh <- sapply(.lh, length) .osplt <- rep(1:length(.lh), .nlh) .lini <- list(inits$THTA, unlist(.lh)) .nlini <- sapply(.lini, length) .nsplt <- rep(1:length(.lini), .nlini) .om0 <- .genOM(.lh) if (length(etaNames) == dim(.om0)[1]) { .ret$etaNames <- .ret$etaNames } else { .ret$etaNames <- sprintf("ETA[%d]", seq(1, dim(.om0)[1])) } .ret$rxInv <- RxODE::rxSymInvCholCreate(mat = .om0, diag.xform = control$diagXform) .ret$xType <- .ret$rxInv$xType .om0a <- .om0 .om0a <- .om0a/control$diagOmegaBoundLower .om0b <- .om0 .om0b <- .om0b * control$diagOmegaBoundUpper .om0a <- RxODE::rxSymInvCholCreate(mat = .om0a, diag.xform = control$diagXform) .om0b <- RxODE::rxSymInvCholCreate(mat = .om0b, diag.xform = control$diagXform) .omdf <- data.frame(a = .om0a$theta, m = .ret$rxInv$theta, b = .om0b$theta, diag = .om0a$theta.diag) .omdf$lower <- with(.omdf, ifelse(a > b, b, a)) .omdf$lower <- with(.omdf, ifelse(lower == m, -Inf, lower)) .omdf$lower <- with(.omdf, ifelse(!diag, -Inf, lower)) .omdf$upper <- with(.omdf, ifelse(a < b, b, a)) .omdf$upper <- with(.omdf, ifelse(upper == m, Inf, upper)) .omdf$upper <- with(.omdf, ifelse(!diag, Inf, upper)) .ret$control$nomega <- length(.omdf$lower) .ret$control$neta <- sum(.omdf$diag) .ret$control$ntheta <- length(lower) .ret$control$nfixed <- sum(fixed) lower <- c(lower, .omdf$lower) upper <- c(upper, .omdf$upper) } else { .ret$control$nomega <- 0 .ret$control$neta <- 0 .ret$xType <- -1 .ret$control$ntheta <- length(lower) .ret$control$nfixed <- sum(fixed) } .ret$lower <- lower .ret$upper <- upper .ret$thetaIni <- inits$THTA .scaleC <- double(length(lower)) if (is.null(control$scaleC)) { .scaleC <- rep(NA_real_, length(lower)) } else { .scaleC <- as.double(control$scaleC) if (length(lower) > length(.scaleC)) { .scaleC <- c(.scaleC, rep(NA_real_, length(lower) - length(.scaleC))) } else if (length(lower) < length(.scaleC)) { .scaleC <- .scaleC[seq(1, length(lower))] warning("scaleC control option has more options than estimated population parameters, please check.") } } .ret$scaleC <- .scaleC if (exists("uif", envir = .ret)) { .ini <- as.data.frame(.ret$uif$ini)[!is.na(.ret$uif$ini$err), c("est", "err", "ntheta")] for (.i in seq_along(.ini$err)) { if (is.na(.ret$scaleC[.ini$ntheta[.i]])) { if (any(.ini$err[.i] == c("boxCox", "yeoJohnson", "pow2", "tbs", "tbsYj"))) { .ret$scaleC[.ini$ntheta[.i]] <- 1 } else if (any(.ini$err[.i] == c("prop", "add", "norm", "dnorm", "logn", "dlogn", "lnorm", "dlnorm"))) { .ret$scaleC[.ini$ntheta[.i]] <- 0.5 * abs(.ini$est[.i]) } } } for (.i in .ini$model$extraProps$powTheta) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- 1 } .ini <- as.data.frame(.ret$uif$ini) for (.i in .ini$model$extraProps$factorial) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- abs(1/digamma(.ini$est[.i] + 1)) } for (.i in .ini$model$extraProps$gamma) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- abs(1/digamma(.ini$est[.i])) } for (.i in .ini$model$extraProps$log) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- log(abs(.ini$est[.i])) * abs(.ini$est[.i]) } for (.i in .ret$logitThetas) { .b <- .ret$logitThetasLow[.i] .c <- .ret$logitThetasHi[.i] .a <- .ini$est[.i] if (is.na(.ret$scaleC[.i])) { .ret$scaleC[.i] <- 1 * (-.b + .c) * exp(-.a)/((1 + exp(-.a))^2 * (.b + 1 * (-.b + .c)/(1 + exp(-.a)))) } } } names(.ret$thetaIni) <- sprintf("THETA[%d]", seq_along(.ret$thetaIni)) if (is.null(etaMat) & !is.null(control$etaMat)) { .ret$etaMat <- control$etaMat } else { .ret$etaMat <- etaMat } .ret$setupTime <- (proc.time() - .pt)["elapsed"] if (exists("uif", envir = .ret)) { .tmp <- .ret$uif$logThetasList .ret$logThetas <- .tmp[[1]] .ret$logThetasF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasList .ret$logitThetas <- .tmp[[1]] .ret$logitThetasF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasListLow .ret$logitThetasLow <- .tmp[[1]] .ret$logitThetasLowF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasListHi .ret$logitThetasHi <- .tmp[[1]] .ret$logitThetasHiF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasList .ret$probitThetas <- .tmp[[1]] .ret$probitThetasF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasListLow .ret$probitThetasLow <- .tmp[[1]] .ret$probitThetasLowF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasListHi .ret$probitThetasHi <- .tmp[[1]] .ret$probitThetasHiF <- .tmp[[2]] } else { .ret$logThetasF <- integer(0) .ret$logitThetasF <- integer(0) .ret$logitThetasHiF <- numeric(0) .ret$logitThetasLowF <- numeric(0) .ret$logitThetas <- integer(0) .ret$logitThetasHi <- numeric(0) .ret$logitThetasLow <- numeric(0) .ret$probitThetasF <- integer(0) .ret$probitThetasHiF <- numeric(0) .ret$probitThetasLowF <- numeric(0) .ret$probitThetas <- integer(0) .ret$probitThetasHi <- numeric(0) .ret$probitThetasLow <- numeric(0) } if (exists("noLik", envir = .ret)) { if (!.ret$noLik) { .ret$.params <- c(sprintf("THETA[%d]", seq_along(.ret$thetaIni)), sprintf("ETA[%d]", seq(1, dim(.om0)[1]))) .ret$.thetan <- length(.ret$thetaIni) .ret$nobs <- sum(data$EVID == 0) } } .ret$control$printTop <- TRUE .ret$control$nF <- 0 .est0 <- .ret$thetaIni if (!is.null(.ret$model$pred.nolhs)) { .ret$control$predNeq <- length(.ret$model$pred.nolhs$state) } else { .ret$control$predNeq <- 0L } .fitFun <- function(.ret) { this.env <- environment() assign("err", "theta reset", this.env) while (this.env$err == "theta reset") { assign("err", "", this.env) .ret0 <- tryCatch({ foceiFitCpp_(.ret) }, error = function(e) { if (regexpr("theta reset", e$message) != -1) { assign("zeroOuter", FALSE, this.env) assign("zeroGrad", FALSE, this.env) if (regexpr("theta reset0", e$message) != -1) { assign("zeroGrad", TRUE, this.env) } else if (regexpr("theta resetZ", e$message) != -1) { assign("zeroOuter", TRUE, this.env) } assign("err", "theta reset", this.env) } else { assign("err", e$message, this.env) } }) if (this.env$err == "theta reset") { .nm <- names(.ret$thetaIni) .ret$thetaIni <- setNames(.thetaReset$thetaIni + 0, .nm) .ret$rxInv$theta <- .thetaReset$omegaTheta .ret$control$printTop <- FALSE .ret$etaMat <- .thetaReset$etaMat .ret$control$etaMat <- .thetaReset$etaMat .ret$control$maxInnerIterations <- .thetaReset$maxInnerIterations .ret$control$nF <- .thetaReset$nF .ret$control$gillRetC <- .thetaReset$gillRetC .ret$control$gillRet <- .thetaReset$gillRet .ret$control$gillRet <- .thetaReset$gillRet .ret$control$gillDf <- .thetaReset$gillDf .ret$control$gillDf2 <- .thetaReset$gillDf2 .ret$control$gillErr <- .thetaReset$gillErr .ret$control$rEps <- .thetaReset$rEps .ret$control$aEps <- .thetaReset$aEps .ret$control$rEpsC <- .thetaReset$rEpsC .ret$control$aEpsC <- .thetaReset$aEpsC .ret$control$c1 <- .thetaReset$c1 .ret$control$c2 <- .thetaReset$c2 if (this.env$zeroOuter) { message("Posthoc reset") .ret$control$maxOuterIterations <- 0L } else if (this.env$zeroGrad) { message("Theta reset (zero gradient values); Switch to bobyqa") RxODE::rxReq("minqa") .ret$control$outerOptFun <- .bobyqa .ret$control$outerOpt <- -1L } else { message("Theta reset (ETA drift)") } } } if (this.env$err != "") { stop(this.env$err) } else { return(.ret0) } } .ret0 <- try(.fitFun(.ret)) .n <- 1 while (inherits(.ret0, "try-error") && control$maxOuterIterations != 0 && .n <= control$nRetries) { message(sprintf("Restart %s", .n)) .ret$control$nF <- 0 .estNew <- .est0 + 0.2 * .n * abs(.est0) * stats::runif(length(.est0)) - 0.1 * .n .estNew <- sapply(seq_along(.est0), function(.i) { if (.ret$thetaFixed[.i]) { return(.est0[.i]) } else if (.estNew[.i] < lower[.i]) { return(lower + (.Machine$double.eps)^(1/7)) } else if (.estNew[.i] > upper[.i]) { return(upper - (.Machine$double.eps)^(1/7)) } else { return(.estNew[.i]) } }) .ret$thetaIni <- .estNew .ret0 <- try(.fitFun(.ret)) .n <- .n + 1 } if (inherits(.ret0, "try-error")) stop("Could not fit data.") .ret <- .ret0 if (exists("parHistData", .ret)) { .tmp <- .ret$parHistData .tmp <- .tmp[.tmp$type == "Unscaled", names(.tmp) != "type"] .iter <- .tmp$iter .tmp <- .tmp[, names(.tmp) != "iter"] .ret$parHistStacked <- data.frame(stack(.tmp), iter = .iter) names(.ret$parHistStacked) <- c("val", "par", "iter") .ret$parHist <- data.frame(iter = .iter, .tmp) } if (.mixed) { .etas <- .ret$ranef .thetas <- .ret$fixef .pars <- .Call(`_nlmixr_nlmixrParameters`, .thetas, .etas) .ret$shrink <- .Call(`_nlmixr_calcShrinkOnly`, .ret$omega, .pars$eta.lst, length(.etas$ID)) .updateParFixed(.ret) } else { .updateParFixed(.ret) } if (!exists("table", .ret)) { .ret$table <- tableControl() } if (control$calcTables) { .ret <- addTable(.ret, updateObject = "no", keep = keep, drop = drop, table = .ret$table) } .ret})(data = dat, inits = .FoceiInits, PKpars = .pars, model = .mod, pred = function() { return(nlmixr_pred) }, err = uif$error, lower = uif$focei.lower, upper = uif$focei.upper, fixed = uif$focei.fixed, thetaNames = uif$focei.names, etaNames = uif$eta.names, control = control, env = env, keep = .keep, drop = .drop): Not all the covariates are in the dataset.</span></div><div class='output co'>#> <span class='message'>Timing stopped at: 8.455 0.377 8.841</span></div><div class='input'><span class='va'>f_nlmixr_dfop_sfo_focei_tc</span> <span class='op'><-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr</a></span><span class='op'>(</span><span class='va'>f_mmkin_tc</span><span class='op'>[</span><span class='st'>"DFOP-SFO"</span>, <span class='op'>]</span>, est <span class='op'>=</span> <span class='st'>"focei"</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> parameter labels from comments are typically ignored in non-interactive mode</span></div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> Need to run with the source intact to parse comments</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ calculate jacobian</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate sensitivities</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(f)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(R²)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling inner model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling EBE model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ compiling events FD model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>Model:</span></div><div class='output co'>#> <span class='message'>cmt(parent);</span>
#> <span class='message'>cmt(A1);</span>
#> <span class='message'>rx_expr_6~ETA[1]+THETA[1];</span>
#> <span class='message'>parent(0)=rx_expr_6;</span>
#> <span class='message'>rx_expr_7~ETA[4]+THETA[4];</span>
#> <span class='message'>rx_expr_8~ETA[6]+THETA[6];</span>
#> <span class='message'>rx_expr_9~ETA[5]+THETA[5];</span>
#> <span class='message'>rx_expr_12~exp(rx_expr_7);</span>
#> <span class='message'>rx_expr_13~exp(rx_expr_9);</span>
#> <span class='message'>rx_expr_15~t*rx_expr_12;</span>
#> <span class='message'>rx_expr_16~t*rx_expr_13;</span>
#> <span class='message'>rx_expr_19~exp(-(rx_expr_8));</span>
#> <span class='message'>rx_expr_21~1+rx_expr_19;</span>
#> <span class='message'>rx_expr_26~1/(rx_expr_21);</span>
#> <span class='message'>rx_expr_28~(rx_expr_26);</span>
#> <span class='message'>rx_expr_29~1-rx_expr_28;</span>
#> <span class='message'>d/dt(parent)=-parent*(exp(rx_expr_7-rx_expr_15)/(rx_expr_21)+exp(rx_expr_9-rx_expr_16)*(rx_expr_29))/(exp(-t*rx_expr_12)/(rx_expr_21)+exp(-t*rx_expr_13)*(rx_expr_29));</span>
#> <span class='message'>rx_expr_10~ETA[2]+THETA[2];</span>
#> <span class='message'>rx_expr_14~exp(rx_expr_10);</span>
#> <span class='message'>d/dt(A1)=-rx_expr_14*A1+parent*f_parent_to_A1*(exp(rx_expr_7-rx_expr_15)/(rx_expr_21)+exp(rx_expr_9-rx_expr_16)*(rx_expr_29))/(exp(-t*rx_expr_12)/(rx_expr_21)+exp(-t*rx_expr_13)*(rx_expr_29));</span>
#> <span class='message'>rx_expr_0~CMT==2;</span>
#> <span class='message'>rx_expr_1~CMT==1;</span>
#> <span class='message'>rx_expr_2~1-(rx_expr_0);</span>
#> <span class='message'>rx_yj_~2*(rx_expr_2)*(rx_expr_1)+2*(rx_expr_0);</span>
#> <span class='message'>rx_expr_3~(rx_expr_0);</span>
#> <span class='message'>rx_expr_5~(rx_expr_2);</span>
#> <span class='message'>rx_expr_20~rx_expr_5*(rx_expr_1);</span>
#> <span class='message'>rx_lambda_~rx_expr_20+rx_expr_3;</span>
#> <span class='message'>rx_hi_~rx_expr_20+rx_expr_3;</span>
#> <span class='message'>rx_low_~0;</span>
#> <span class='message'>rx_expr_4~A1*(rx_expr_0);</span>
#> <span class='message'>rx_expr_11~parent*(rx_expr_2);</span>
#> <span class='message'>rx_expr_24~rx_expr_11*(rx_expr_1);</span>
#> <span class='message'>rx_pred_=(rx_expr_4+rx_expr_24)*(rx_expr_0)+(rx_expr_4+rx_expr_24)*(rx_expr_2)*(rx_expr_1);</span>
#> <span class='message'>rx_expr_17~Rx_pow_di(THETA[8],2);</span>
#> <span class='message'>rx_expr_18~Rx_pow_di(THETA[7],2);</span>
#> <span class='message'>rx_r_=(Rx_pow_di(((rx_expr_4+rx_expr_24)*(rx_expr_0)+(rx_expr_4+rx_expr_24)*(rx_expr_2)*(rx_expr_1)),2)*rx_expr_17+rx_expr_18)*(rx_expr_0)+(rx_expr_17*Rx_pow_di(((rx_expr_4+rx_expr_24)*(rx_expr_1)),2)+rx_expr_18)*(rx_expr_2)*(rx_expr_1);</span>
#> <span class='message'>parent_0=THETA[1];</span>
#> <span class='message'>log_k_A1=THETA[2];</span>
#> <span class='message'>f_parent_qlogis=THETA[3];</span>
#> <span class='message'>log_k1=THETA[4];</span>
#> <span class='message'>log_k2=THETA[5];</span>
#> <span class='message'>g_qlogis=THETA[6];</span>
#> <span class='message'>sigma_low=THETA[7];</span>
#> <span class='message'>rsd_high=THETA[8];</span>
#> <span class='message'>eta.parent_0=ETA[1];</span>
#> <span class='message'>eta.log_k_A1=ETA[2];</span>
#> <span class='message'>eta.f_parent_qlogis=ETA[3];</span>
#> <span class='message'>eta.log_k1=ETA[4];</span>
#> <span class='message'>eta.log_k2=ETA[5];</span>
#> <span class='message'>eta.g_qlogis=ETA[6];</span>
#> <span class='message'>parent_0_model=rx_expr_6;</span>
#> <span class='message'>k_A1=rx_expr_14;</span>
#> <span class='message'>k1=rx_expr_12;</span>
#> <span class='message'>k2=rx_expr_13;</span>
#> <span class='message'>f_parent=1/(1+exp(-(ETA[3]+THETA[3])));</span>
#> <span class='message'>g=1/(rx_expr_21);</span>
#> <span class='message'>tad=tad();</span>
#> <span class='message'>dosenum=dosenum();</span></div><div class='output co'>#> <span class='message'>Needed Covariates:</span></div><div class='output co'>#> <span class='message'>[1] "f_parent_to_A1" "CMT" </span></div><div class='output co'>#> <span class='error'>Error in (function (data, inits, PKpars, model = NULL, pred = NULL, err = NULL, lower = -Inf, upper = Inf, fixed = NULL, skipCov = NULL, control = foceiControl(), thetaNames = NULL, etaNames = NULL, etaMat = NULL, ..., env = NULL, keep = NULL, drop = NULL) { set.seed(control$seed) .pt <- proc.time() RxODE::.setWarnIdSort(FALSE) on.exit(RxODE::.setWarnIdSort(TRUE)) loadNamespace("n1qn1") if (!RxODE::rxIs(control, "foceiControl")) { control <- do.call(foceiControl, control) } if (is.null(env)) { .ret <- new.env(parent = emptyenv()) } else { .ret <- env } .ret$origData <- data .ret$etaNames <- etaNames .ret$thetaFixed <- fixed .ret$control <- control .ret$control$focei.mu.ref <- integer(0) if (is(model, "RxODE") || is(model, "character")) { .ret$ODEmodel <- TRUE if (class(pred) != "function") { stop("pred must be a function specifying the prediction variables in this model.") } } else { .ret$ODEmodel <- TRUE model <- RxODE::rxGetLin(PKpars) pred <- eval(parse(text = "function(){return(Central);}")) } .square <- function(x) x * x .ret$diagXformInv <- c(sqrt = ".square", log = "exp", identity = "identity")[control$diagXform] if (is.null(err)) { err <- eval(parse(text = paste0("function(){err", paste(inits$ERROR[[1]], collapse = ""), "}"))) } .covNames <- .parNames <- c() .ret$adjLik <- control$adjLik .mixed <- !is.null(inits$OMGA) && length(inits$OMGA) > 0 if (!exists("noLik", envir = .ret)) { .atol <- rep(control$atol, length(RxODE::rxModelVars(model)$state)) .rtol <- rep(control$rtol, length(RxODE::rxModelVars(model)$state)) .ssAtol <- rep(control$ssAtol, length(RxODE::rxModelVars(model)$state)) .ssRtol <- rep(control$ssRtol, length(RxODE::rxModelVars(model)$state)) .ret$model <- RxODE::rxSymPySetupPred(model, pred, PKpars, err, grad = (control$derivMethod == 2L), pred.minus.dv = TRUE, sum.prod = control$sumProd, theta.derivs = FALSE, optExpression = control$optExpression, interaction = (control$interaction == 1L), only.numeric = !.mixed, run.internal = TRUE, addProp = control$addProp) if (!is.null(.ret$model$inner)) { .atol <- c(.atol, rep(control$atolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.atol))) .rtol <- c(.rtol, rep(control$rtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.rtol))) .ret$control$rxControl$atol <- .atol .ret$control$rxControl$rtol <- .rtol .ssAtol <- c(.ssAtol, rep(control$ssAtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.ssAtol))) .ssRtol <- c(.ssRtol, rep(control$ssRtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.ssRtol))) .ret$control$rxControl$ssAtol <- .ssAtol .ret$control$rxControl$ssRtol <- .ssRtol } .covNames <- .parNames <- RxODE::rxParams(.ret$model$pred.only) .covNames <- .covNames[regexpr(rex::rex(start, or("THETA", "ETA"), "[", numbers, "]", end), .covNames) == -1] colnames(data) <- sapply(names(data), function(x) { if (any(x == .covNames)) { return(x) } else { return(toupper(x)) } }) .lhs <- c(names(RxODE::rxInits(.ret$model$pred.only)), RxODE::rxLhs(.ret$model$pred.only)) if (length(.lhs) > 0) { .covNames <- .covNames[regexpr(rex::rex(start, or(.lhs), end), .covNames) == -1] } if (length(.covNames) > 0) { if (!all(.covNames %in% names(data))) { message("Model:") RxODE::rxCat(.ret$model$pred.only) message("Needed Covariates:") nlmixrPrint(.covNames) stop("Not all the covariates are in the dataset.") } message("Needed Covariates:") print(.covNames) } .extraPars <- .ret$model$extra.pars } else { if (.ret$noLik) { .atol <- rep(control$atol, length(RxODE::rxModelVars(model)$state)) .rtol <- rep(control$rtol, length(RxODE::rxModelVars(model)$state)) .ret$model <- RxODE::rxSymPySetupPred(model, pred, PKpars, err, grad = FALSE, pred.minus.dv = TRUE, sum.prod = control$sumProd, theta.derivs = FALSE, optExpression = control$optExpression, run.internal = TRUE, only.numeric = TRUE, addProp = control$addProp) if (!is.null(.ret$model$inner)) { .atol <- c(.atol, rep(control$atolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.atol))) .rtol <- c(.rtol, rep(control$rtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.rtol))) .ret$control$rxControl$atol <- .atol .ret$control$rxControl$rtol <- .rtol } .covNames <- .parNames <- RxODE::rxParams(.ret$model$pred.only) .covNames <- .covNames[regexpr(rex::rex(start, or("THETA", "ETA"), "[", numbers, "]", end), .covNames) == -1] colnames(data) <- sapply(names(data), function(x) { if (any(x == .covNames)) { return(x) } else { return(toupper(x)) } }) .lhs <- c(names(RxODE::rxInits(.ret$model$pred.only)), RxODE::rxLhs(.ret$model$pred.only)) if (length(.lhs) > 0) { .covNames <- .covNames[regexpr(rex::rex(start, or(.lhs), end), .covNames) == -1] } if (length(.covNames) > 0) { if (!all(.covNames %in% names(data))) { message("Model:") RxODE::rxCat(.ret$model$pred.only) message("Needed Covariates:") nlmixrPrint(.covNames) stop("Not all the covariates are in the dataset.") } message("Needed Covariates:") print(.covNames) } .extraPars <- .ret$model$extra.pars } else { .extraPars <- NULL } } .ret$skipCov <- skipCov if (is.null(skipCov)) { if (is.null(fixed)) { .tmp <- rep(FALSE, length(inits$THTA)) } else { if (length(fixed) < length(inits$THTA)) { .tmp <- c(fixed, rep(FALSE, length(inits$THTA) - length(fixed))) } else { .tmp <- fixed[1:length(inits$THTA)] } } if (exists("uif", envir = .ret)) { .uifErr <- .ret$uif$ini$err[!is.na(.ret$uif$ini$ntheta)] .uifErr <- sapply(.uifErr, function(x) { if (is.na(x)) { return(FALSE) } return(!any(x == c("pow2", "tbs", "tbsYj"))) }) .tmp <- (.tmp | .uifErr) } .ret$skipCov <- c(.tmp, rep(TRUE, length(.extraPars))) .ret$control$focei.mu.ref <- .ret$uif$focei.mu.ref } if (is.null(.extraPars)) { .nms <- c(sprintf("THETA[%s]", seq_along(inits$THTA))) } else { .nms <- c(sprintf("THETA[%s]", seq_along(inits$THTA)), sprintf("ERR[%s]", seq_along(.extraPars))) } if (!is.null(thetaNames) && (length(inits$THTA) + length(.extraPars)) == length(thetaNames)) { .nms <- thetaNames } .ret$thetaNames <- .nms .thetaReset$thetaNames <- .nms if (length(lower) == 1) { lower <- rep(lower, length(inits$THTA)) } else if (length(lower) != length(inits$THTA)) { print(inits$THTA) print(lower) stop("Lower must be a single constant for all the THETA lower bounds, or match the dimension of THETA.") } if (length(upper) == 1) { upper <- rep(upper, length(inits$THTA)) } else if (length(lower) != length(inits$THTA)) { stop("Upper must be a single constant for all the THETA lower bounds, or match the dimension of THETA.") } if (!is.null(.extraPars)) { .ret$model$extra.pars <- eval(call(control$diagXform, .ret$model$extra.pars)) if (length(.ret$model$extra.pars) > 0) { inits$THTA <- c(inits$THTA, .ret$model$extra.pars) .lowerErr <- rep(control$atol[1] * 10, length(.ret$model$extra.pars)) .upperErr <- rep(Inf, length(.ret$model$extra.pars)) lower <- c(lower, .lowerErr) upper <- c(upper, .upperErr) } } if (is.null(data$ID)) stop("\"ID\" not found in data") if (is.null(data$DV)) stop("\"DV\" not found in data") if (is.null(data$EVID)) data$EVID <- 0 if (is.null(data$AMT)) data$AMT <- 0 for (.v in c("TIME", "AMT", "DV", .covNames)) { data[[.v]] <- as.double(data[[.v]]) } .ret$dataSav <- data .ds <- data[data$EVID != 0 & data$EVID != 2, c("ID", "TIME", "AMT", "EVID", .covNames)] .w <- which(tolower(names(data)) == "limit") .limitName <- NULL if (length(.w) == 1L) { .limitName <- names(data)[.w] } .censName <- NULL .w <- which(tolower(names(data)) == "cens") if (length(.w) == 1L) { .censName <- names(data[.w]) } data <- data[data$EVID == 0 | data$EVID == 2, c("ID", "TIME", "DV", "EVID", .covNames, .limitName, .censName)] .w <- which(!(names(.ret$dataSav) %in% c(.covNames, keep))) names(.ret$dataSav)[.w] <- tolower(names(.ret$dataSav[.w])) if (.mixed) { .lh <- .parseOM(inits$OMGA) .nlh <- sapply(.lh, length) .osplt <- rep(1:length(.lh), .nlh) .lini <- list(inits$THTA, unlist(.lh)) .nlini <- sapply(.lini, length) .nsplt <- rep(1:length(.lini), .nlini) .om0 <- .genOM(.lh) if (length(etaNames) == dim(.om0)[1]) { .ret$etaNames <- .ret$etaNames } else { .ret$etaNames <- sprintf("ETA[%d]", seq(1, dim(.om0)[1])) } .ret$rxInv <- RxODE::rxSymInvCholCreate(mat = .om0, diag.xform = control$diagXform) .ret$xType <- .ret$rxInv$xType .om0a <- .om0 .om0a <- .om0a/control$diagOmegaBoundLower .om0b <- .om0 .om0b <- .om0b * control$diagOmegaBoundUpper .om0a <- RxODE::rxSymInvCholCreate(mat = .om0a, diag.xform = control$diagXform) .om0b <- RxODE::rxSymInvCholCreate(mat = .om0b, diag.xform = control$diagXform) .omdf <- data.frame(a = .om0a$theta, m = .ret$rxInv$theta, b = .om0b$theta, diag = .om0a$theta.diag) .omdf$lower <- with(.omdf, ifelse(a > b, b, a)) .omdf$lower <- with(.omdf, ifelse(lower == m, -Inf, lower)) .omdf$lower <- with(.omdf, ifelse(!diag, -Inf, lower)) .omdf$upper <- with(.omdf, ifelse(a < b, b, a)) .omdf$upper <- with(.omdf, ifelse(upper == m, Inf, upper)) .omdf$upper <- with(.omdf, ifelse(!diag, Inf, upper)) .ret$control$nomega <- length(.omdf$lower) .ret$control$neta <- sum(.omdf$diag) .ret$control$ntheta <- length(lower) .ret$control$nfixed <- sum(fixed) lower <- c(lower, .omdf$lower) upper <- c(upper, .omdf$upper) } else { .ret$control$nomega <- 0 .ret$control$neta <- 0 .ret$xType <- -1 .ret$control$ntheta <- length(lower) .ret$control$nfixed <- sum(fixed) } .ret$lower <- lower .ret$upper <- upper .ret$thetaIni <- inits$THTA .scaleC <- double(length(lower)) if (is.null(control$scaleC)) { .scaleC <- rep(NA_real_, length(lower)) } else { .scaleC <- as.double(control$scaleC) if (length(lower) > length(.scaleC)) { .scaleC <- c(.scaleC, rep(NA_real_, length(lower) - length(.scaleC))) } else if (length(lower) < length(.scaleC)) { .scaleC <- .scaleC[seq(1, length(lower))] warning("scaleC control option has more options than estimated population parameters, please check.") } } .ret$scaleC <- .scaleC if (exists("uif", envir = .ret)) { .ini <- as.data.frame(.ret$uif$ini)[!is.na(.ret$uif$ini$err), c("est", "err", "ntheta")] for (.i in seq_along(.ini$err)) { if (is.na(.ret$scaleC[.ini$ntheta[.i]])) { if (any(.ini$err[.i] == c("boxCox", "yeoJohnson", "pow2", "tbs", "tbsYj"))) { .ret$scaleC[.ini$ntheta[.i]] <- 1 } else if (any(.ini$err[.i] == c("prop", "add", "norm", "dnorm", "logn", "dlogn", "lnorm", "dlnorm"))) { .ret$scaleC[.ini$ntheta[.i]] <- 0.5 * abs(.ini$est[.i]) } } } for (.i in .ini$model$extraProps$powTheta) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- 1 } .ini <- as.data.frame(.ret$uif$ini) for (.i in .ini$model$extraProps$factorial) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- abs(1/digamma(.ini$est[.i] + 1)) } for (.i in .ini$model$extraProps$gamma) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- abs(1/digamma(.ini$est[.i])) } for (.i in .ini$model$extraProps$log) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- log(abs(.ini$est[.i])) * abs(.ini$est[.i]) } for (.i in .ret$logitThetas) { .b <- .ret$logitThetasLow[.i] .c <- .ret$logitThetasHi[.i] .a <- .ini$est[.i] if (is.na(.ret$scaleC[.i])) { .ret$scaleC[.i] <- 1 * (-.b + .c) * exp(-.a)/((1 + exp(-.a))^2 * (.b + 1 * (-.b + .c)/(1 + exp(-.a)))) } } } names(.ret$thetaIni) <- sprintf("THETA[%d]", seq_along(.ret$thetaIni)) if (is.null(etaMat) & !is.null(control$etaMat)) { .ret$etaMat <- control$etaMat } else { .ret$etaMat <- etaMat } .ret$setupTime <- (proc.time() - .pt)["elapsed"] if (exists("uif", envir = .ret)) { .tmp <- .ret$uif$logThetasList .ret$logThetas <- .tmp[[1]] .ret$logThetasF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasList .ret$logitThetas <- .tmp[[1]] .ret$logitThetasF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasListLow .ret$logitThetasLow <- .tmp[[1]] .ret$logitThetasLowF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasListHi .ret$logitThetasHi <- .tmp[[1]] .ret$logitThetasHiF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasList .ret$probitThetas <- .tmp[[1]] .ret$probitThetasF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasListLow .ret$probitThetasLow <- .tmp[[1]] .ret$probitThetasLowF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasListHi .ret$probitThetasHi <- .tmp[[1]] .ret$probitThetasHiF <- .tmp[[2]] } else { .ret$logThetasF <- integer(0) .ret$logitThetasF <- integer(0) .ret$logitThetasHiF <- numeric(0) .ret$logitThetasLowF <- numeric(0) .ret$logitThetas <- integer(0) .ret$logitThetasHi <- numeric(0) .ret$logitThetasLow <- numeric(0) .ret$probitThetasF <- integer(0) .ret$probitThetasHiF <- numeric(0) .ret$probitThetasLowF <- numeric(0) .ret$probitThetas <- integer(0) .ret$probitThetasHi <- numeric(0) .ret$probitThetasLow <- numeric(0) } if (exists("noLik", envir = .ret)) { if (!.ret$noLik) { .ret$.params <- c(sprintf("THETA[%d]", seq_along(.ret$thetaIni)), sprintf("ETA[%d]", seq(1, dim(.om0)[1]))) .ret$.thetan <- length(.ret$thetaIni) .ret$nobs <- sum(data$EVID == 0) } } .ret$control$printTop <- TRUE .ret$control$nF <- 0 .est0 <- .ret$thetaIni if (!is.null(.ret$model$pred.nolhs)) { .ret$control$predNeq <- length(.ret$model$pred.nolhs$state) } else { .ret$control$predNeq <- 0L } .fitFun <- function(.ret) { this.env <- environment() assign("err", "theta reset", this.env) while (this.env$err == "theta reset") { assign("err", "", this.env) .ret0 <- tryCatch({ foceiFitCpp_(.ret) }, error = function(e) { if (regexpr("theta reset", e$message) != -1) { assign("zeroOuter", FALSE, this.env) assign("zeroGrad", FALSE, this.env) if (regexpr("theta reset0", e$message) != -1) { assign("zeroGrad", TRUE, this.env) } else if (regexpr("theta resetZ", e$message) != -1) { assign("zeroOuter", TRUE, this.env) } assign("err", "theta reset", this.env) } else { assign("err", e$message, this.env) } }) if (this.env$err == "theta reset") { .nm <- names(.ret$thetaIni) .ret$thetaIni <- setNames(.thetaReset$thetaIni + 0, .nm) .ret$rxInv$theta <- .thetaReset$omegaTheta .ret$control$printTop <- FALSE .ret$etaMat <- .thetaReset$etaMat .ret$control$etaMat <- .thetaReset$etaMat .ret$control$maxInnerIterations <- .thetaReset$maxInnerIterations .ret$control$nF <- .thetaReset$nF .ret$control$gillRetC <- .thetaReset$gillRetC .ret$control$gillRet <- .thetaReset$gillRet .ret$control$gillRet <- .thetaReset$gillRet .ret$control$gillDf <- .thetaReset$gillDf .ret$control$gillDf2 <- .thetaReset$gillDf2 .ret$control$gillErr <- .thetaReset$gillErr .ret$control$rEps <- .thetaReset$rEps .ret$control$aEps <- .thetaReset$aEps .ret$control$rEpsC <- .thetaReset$rEpsC .ret$control$aEpsC <- .thetaReset$aEpsC .ret$control$c1 <- .thetaReset$c1 .ret$control$c2 <- .thetaReset$c2 if (this.env$zeroOuter) { message("Posthoc reset") .ret$control$maxOuterIterations <- 0L } else if (this.env$zeroGrad) { message("Theta reset (zero gradient values); Switch to bobyqa") RxODE::rxReq("minqa") .ret$control$outerOptFun <- .bobyqa .ret$control$outerOpt <- -1L } else { message("Theta reset (ETA drift)") } } } if (this.env$err != "") { stop(this.env$err) } else { return(.ret0) } } .ret0 <- try(.fitFun(.ret)) .n <- 1 while (inherits(.ret0, "try-error") && control$maxOuterIterations != 0 && .n <= control$nRetries) { message(sprintf("Restart %s", .n)) .ret$control$nF <- 0 .estNew <- .est0 + 0.2 * .n * abs(.est0) * stats::runif(length(.est0)) - 0.1 * .n .estNew <- sapply(seq_along(.est0), function(.i) { if (.ret$thetaFixed[.i]) { return(.est0[.i]) } else if (.estNew[.i] < lower[.i]) { return(lower + (.Machine$double.eps)^(1/7)) } else if (.estNew[.i] > upper[.i]) { return(upper - (.Machine$double.eps)^(1/7)) } else { return(.estNew[.i]) } }) .ret$thetaIni <- .estNew .ret0 <- try(.fitFun(.ret)) .n <- .n + 1 } if (inherits(.ret0, "try-error")) stop("Could not fit data.") .ret <- .ret0 if (exists("parHistData", .ret)) { .tmp <- .ret$parHistData .tmp <- .tmp[.tmp$type == "Unscaled", names(.tmp) != "type"] .iter <- .tmp$iter .tmp <- .tmp[, names(.tmp) != "iter"] .ret$parHistStacked <- data.frame(stack(.tmp), iter = .iter) names(.ret$parHistStacked) <- c("val", "par", "iter") .ret$parHist <- data.frame(iter = .iter, .tmp) } if (.mixed) { .etas <- .ret$ranef .thetas <- .ret$fixef .pars <- .Call(`_nlmixr_nlmixrParameters`, .thetas, .etas) .ret$shrink <- .Call(`_nlmixr_calcShrinkOnly`, .ret$omega, .pars$eta.lst, length(.etas$ID)) .updateParFixed(.ret) } else { .updateParFixed(.ret) } if (!exists("table", .ret)) { .ret$table <- tableControl() } if (control$calcTables) { .ret <- addTable(.ret, updateObject = "no", keep = keep, drop = drop, table = .ret$table) } .ret})(data = dat, inits = .FoceiInits, PKpars = .pars, model = .mod, pred = function() { return(nlmixr_pred) }, err = uif$error, lower = uif$focei.lower, upper = uif$focei.upper, fixed = uif$focei.fixed, thetaNames = uif$focei.names, etaNames = uif$eta.names, control = control, env = env, keep = .keep, drop = .drop): Not all the covariates are in the dataset.</span></div><div class='output co'>#> <span class='message'>Timing stopped at: 17.73 0.679 18.41</span></div><div class='input'>
<span class='co'># Two-component error by variable is possible with both estimation methods</span>
<span class='co'># Variance by variable is supported by 'saem' and 'focei'</span>
<span class='va'>f_nlmixr_fomc_sfo_saem_obs_tc</span> <span class='op'><-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr</a></span><span class='op'>(</span><span class='va'>f_mmkin_tc</span><span class='op'>[</span><span class='st'>"FOMC-SFO"</span>, <span class='op'>]</span>, est <span class='op'>=</span> <span class='st'>"saem"</span>,
error_model <span class='op'>=</span> <span class='st'>"obs_tc"</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> parameter labels from comments are typically ignored in non-interactive mode</span></div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> Need to run with the source intact to parse comments</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='error'>Error in configsaem(model = model, data = dat, inits = inits, mcmc = .mcmc, ODEopt = .ODEopt, seed = .seed, distribution = .dist, DEBUG = .DEBUG, addProp = .addProp, tol = .tol, itmax = .itmax, type = .type, powRange = .powRange, lambdaRange = .lambdaRange): covariate(s) not found: f_parent_to_A1</span></div><div class='output co'>#> <span class='message'>Timing stopped at: 0.775 0.024 0.799</span></div><div class='input'><span class='va'>f_nlmixr_fomc_sfo_focei_obs_tc</span> <span class='op'><-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr</a></span><span class='op'>(</span><span class='va'>f_mmkin_tc</span><span class='op'>[</span><span class='st'>"FOMC-SFO"</span>, <span class='op'>]</span>, est <span class='op'>=</span> <span class='st'>"focei"</span>,
error_model <span class='op'>=</span> <span class='st'>"obs_tc"</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> parameter labels from comments are typically ignored in non-interactive mode</span></div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> Need to run with the source intact to parse comments</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ calculate jacobian</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate sensitivities</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(f)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(R²)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling inner model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling EBE model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ compiling events FD model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>Model:</span></div><div class='output co'>#> <span class='message'>cmt(parent);</span>
#> <span class='message'>cmt(A1);</span>
#> <span class='message'>rx_expr_6~ETA[1]+THETA[1];</span>
#> <span class='message'>parent(0)=rx_expr_6;</span>
#> <span class='message'>rx_expr_7~ETA[4]+THETA[4];</span>
#> <span class='message'>rx_expr_8~ETA[5]+THETA[5];</span>
#> <span class='message'>rx_expr_12~exp(-(rx_expr_8));</span>
#> <span class='message'>rx_expr_14~t*rx_expr_12;</span>
#> <span class='message'>rx_expr_15~1+rx_expr_14;</span>
#> <span class='message'>rx_expr_17~rx_expr_7-(rx_expr_8);</span>
#> <span class='message'>rx_expr_19~exp(rx_expr_17);</span>
#> <span class='message'>d/dt(parent)=-rx_expr_19*parent/(rx_expr_15);</span>
#> <span class='message'>rx_expr_9~ETA[2]+THETA[2];</span>
#> <span class='message'>rx_expr_11~exp(rx_expr_9);</span>
#> <span class='message'>d/dt(A1)=-rx_expr_11*A1+rx_expr_19*parent*f_parent_to_A1/(rx_expr_15);</span>
#> <span class='message'>rx_expr_0~CMT==2;</span>
#> <span class='message'>rx_expr_1~CMT==1;</span>
#> <span class='message'>rx_expr_2~1-(rx_expr_0);</span>
#> <span class='message'>rx_yj_~2*(rx_expr_2)*(rx_expr_1)+2*(rx_expr_0);</span>
#> <span class='message'>rx_expr_3~(rx_expr_0);</span>
#> <span class='message'>rx_expr_5~(rx_expr_2);</span>
#> <span class='message'>rx_expr_13~rx_expr_5*(rx_expr_1);</span>
#> <span class='message'>rx_lambda_~rx_expr_13+rx_expr_3;</span>
#> <span class='message'>rx_hi_~rx_expr_13+rx_expr_3;</span>
#> <span class='message'>rx_low_~0;</span>
#> <span class='message'>rx_expr_4~A1*(rx_expr_0);</span>
#> <span class='message'>rx_expr_10~parent*(rx_expr_2);</span>
#> <span class='message'>rx_expr_16~rx_expr_10*(rx_expr_1);</span>
#> <span class='message'>rx_pred_=(rx_expr_4+rx_expr_16)*(rx_expr_0)+(rx_expr_4+rx_expr_16)*(rx_expr_2)*(rx_expr_1);</span>
#> <span class='message'>rx_r_=(Rx_pow_di(((rx_expr_4+rx_expr_16)*(rx_expr_0)+(rx_expr_4+rx_expr_16)*(rx_expr_2)*(rx_expr_1)),2)*Rx_pow_di(THETA[9],2)+Rx_pow_di(THETA[8],2))*(rx_expr_0)+(Rx_pow_di(THETA[7],2)*Rx_pow_di(((rx_expr_4+rx_expr_16)*(rx_expr_1)),2)+Rx_pow_di(THETA[6],2))*(rx_expr_2)*(rx_expr_1);</span>
#> <span class='message'>parent_0=THETA[1];</span>
#> <span class='message'>log_k_A1=THETA[2];</span>
#> <span class='message'>f_parent_qlogis=THETA[3];</span>
#> <span class='message'>log_alpha=THETA[4];</span>
#> <span class='message'>log_beta=THETA[5];</span>
#> <span class='message'>sigma_low_parent=THETA[6];</span>
#> <span class='message'>rsd_high_parent=THETA[7];</span>
#> <span class='message'>sigma_low_A1=THETA[8];</span>
#> <span class='message'>rsd_high_A1=THETA[9];</span>
#> <span class='message'>eta.parent_0=ETA[1];</span>
#> <span class='message'>eta.log_k_A1=ETA[2];</span>
#> <span class='message'>eta.f_parent_qlogis=ETA[3];</span>
#> <span class='message'>eta.log_alpha=ETA[4];</span>
#> <span class='message'>eta.log_beta=ETA[5];</span>
#> <span class='message'>parent_0_model=rx_expr_6;</span>
#> <span class='message'>k_A1=rx_expr_11;</span>
#> <span class='message'>alpha=exp(rx_expr_7);</span>
#> <span class='message'>beta=exp(rx_expr_8);</span>
#> <span class='message'>f_parent=1/(1+exp(-(ETA[3]+THETA[3])));</span>
#> <span class='message'>tad=tad();</span>
#> <span class='message'>dosenum=dosenum();</span></div><div class='output co'>#> <span class='message'>Needed Covariates:</span></div><div class='output co'>#> <span class='message'>[1] "f_parent_to_A1" "CMT" </span></div><div class='output co'>#> <span class='error'>Error in (function (data, inits, PKpars, model = NULL, pred = NULL, err = NULL, lower = -Inf, upper = Inf, fixed = NULL, skipCov = NULL, control = foceiControl(), thetaNames = NULL, etaNames = NULL, etaMat = NULL, ..., env = NULL, keep = NULL, drop = NULL) { set.seed(control$seed) .pt <- proc.time() RxODE::.setWarnIdSort(FALSE) on.exit(RxODE::.setWarnIdSort(TRUE)) loadNamespace("n1qn1") if (!RxODE::rxIs(control, "foceiControl")) { control <- do.call(foceiControl, control) } if (is.null(env)) { .ret <- new.env(parent = emptyenv()) } else { .ret <- env } .ret$origData <- data .ret$etaNames <- etaNames .ret$thetaFixed <- fixed .ret$control <- control .ret$control$focei.mu.ref <- integer(0) if (is(model, "RxODE") || is(model, "character")) { .ret$ODEmodel <- TRUE if (class(pred) != "function") { stop("pred must be a function specifying the prediction variables in this model.") } } else { .ret$ODEmodel <- TRUE model <- RxODE::rxGetLin(PKpars) pred <- eval(parse(text = "function(){return(Central);}")) } .square <- function(x) x * x .ret$diagXformInv <- c(sqrt = ".square", log = "exp", identity = "identity")[control$diagXform] if (is.null(err)) { err <- eval(parse(text = paste0("function(){err", paste(inits$ERROR[[1]], collapse = ""), "}"))) } .covNames <- .parNames <- c() .ret$adjLik <- control$adjLik .mixed <- !is.null(inits$OMGA) && length(inits$OMGA) > 0 if (!exists("noLik", envir = .ret)) { .atol <- rep(control$atol, length(RxODE::rxModelVars(model)$state)) .rtol <- rep(control$rtol, length(RxODE::rxModelVars(model)$state)) .ssAtol <- rep(control$ssAtol, length(RxODE::rxModelVars(model)$state)) .ssRtol <- rep(control$ssRtol, length(RxODE::rxModelVars(model)$state)) .ret$model <- RxODE::rxSymPySetupPred(model, pred, PKpars, err, grad = (control$derivMethod == 2L), pred.minus.dv = TRUE, sum.prod = control$sumProd, theta.derivs = FALSE, optExpression = control$optExpression, interaction = (control$interaction == 1L), only.numeric = !.mixed, run.internal = TRUE, addProp = control$addProp) if (!is.null(.ret$model$inner)) { .atol <- c(.atol, rep(control$atolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.atol))) .rtol <- c(.rtol, rep(control$rtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.rtol))) .ret$control$rxControl$atol <- .atol .ret$control$rxControl$rtol <- .rtol .ssAtol <- c(.ssAtol, rep(control$ssAtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.ssAtol))) .ssRtol <- c(.ssRtol, rep(control$ssRtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.ssRtol))) .ret$control$rxControl$ssAtol <- .ssAtol .ret$control$rxControl$ssRtol <- .ssRtol } .covNames <- .parNames <- RxODE::rxParams(.ret$model$pred.only) .covNames <- .covNames[regexpr(rex::rex(start, or("THETA", "ETA"), "[", numbers, "]", end), .covNames) == -1] colnames(data) <- sapply(names(data), function(x) { if (any(x == .covNames)) { return(x) } else { return(toupper(x)) } }) .lhs <- c(names(RxODE::rxInits(.ret$model$pred.only)), RxODE::rxLhs(.ret$model$pred.only)) if (length(.lhs) > 0) { .covNames <- .covNames[regexpr(rex::rex(start, or(.lhs), end), .covNames) == -1] } if (length(.covNames) > 0) { if (!all(.covNames %in% names(data))) { message("Model:") RxODE::rxCat(.ret$model$pred.only) message("Needed Covariates:") nlmixrPrint(.covNames) stop("Not all the covariates are in the dataset.") } message("Needed Covariates:") print(.covNames) } .extraPars <- .ret$model$extra.pars } else { if (.ret$noLik) { .atol <- rep(control$atol, length(RxODE::rxModelVars(model)$state)) .rtol <- rep(control$rtol, length(RxODE::rxModelVars(model)$state)) .ret$model <- RxODE::rxSymPySetupPred(model, pred, PKpars, err, grad = FALSE, pred.minus.dv = TRUE, sum.prod = control$sumProd, theta.derivs = FALSE, optExpression = control$optExpression, run.internal = TRUE, only.numeric = TRUE, addProp = control$addProp) if (!is.null(.ret$model$inner)) { .atol <- c(.atol, rep(control$atolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.atol))) .rtol <- c(.rtol, rep(control$rtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.rtol))) .ret$control$rxControl$atol <- .atol .ret$control$rxControl$rtol <- .rtol } .covNames <- .parNames <- RxODE::rxParams(.ret$model$pred.only) .covNames <- .covNames[regexpr(rex::rex(start, or("THETA", "ETA"), "[", numbers, "]", end), .covNames) == -1] colnames(data) <- sapply(names(data), function(x) { if (any(x == .covNames)) { return(x) } else { return(toupper(x)) } }) .lhs <- c(names(RxODE::rxInits(.ret$model$pred.only)), RxODE::rxLhs(.ret$model$pred.only)) if (length(.lhs) > 0) { .covNames <- .covNames[regexpr(rex::rex(start, or(.lhs), end), .covNames) == -1] } if (length(.covNames) > 0) { if (!all(.covNames %in% names(data))) { message("Model:") RxODE::rxCat(.ret$model$pred.only) message("Needed Covariates:") nlmixrPrint(.covNames) stop("Not all the covariates are in the dataset.") } message("Needed Covariates:") print(.covNames) } .extraPars <- .ret$model$extra.pars } else { .extraPars <- NULL } } .ret$skipCov <- skipCov if (is.null(skipCov)) { if (is.null(fixed)) { .tmp <- rep(FALSE, length(inits$THTA)) } else { if (length(fixed) < length(inits$THTA)) { .tmp <- c(fixed, rep(FALSE, length(inits$THTA) - length(fixed))) } else { .tmp <- fixed[1:length(inits$THTA)] } } if (exists("uif", envir = .ret)) { .uifErr <- .ret$uif$ini$err[!is.na(.ret$uif$ini$ntheta)] .uifErr <- sapply(.uifErr, function(x) { if (is.na(x)) { return(FALSE) } return(!any(x == c("pow2", "tbs", "tbsYj"))) }) .tmp <- (.tmp | .uifErr) } .ret$skipCov <- c(.tmp, rep(TRUE, length(.extraPars))) .ret$control$focei.mu.ref <- .ret$uif$focei.mu.ref } if (is.null(.extraPars)) { .nms <- c(sprintf("THETA[%s]", seq_along(inits$THTA))) } else { .nms <- c(sprintf("THETA[%s]", seq_along(inits$THTA)), sprintf("ERR[%s]", seq_along(.extraPars))) } if (!is.null(thetaNames) && (length(inits$THTA) + length(.extraPars)) == length(thetaNames)) { .nms <- thetaNames } .ret$thetaNames <- .nms .thetaReset$thetaNames <- .nms if (length(lower) == 1) { lower <- rep(lower, length(inits$THTA)) } else if (length(lower) != length(inits$THTA)) { print(inits$THTA) print(lower) stop("Lower must be a single constant for all the THETA lower bounds, or match the dimension of THETA.") } if (length(upper) == 1) { upper <- rep(upper, length(inits$THTA)) } else if (length(lower) != length(inits$THTA)) { stop("Upper must be a single constant for all the THETA lower bounds, or match the dimension of THETA.") } if (!is.null(.extraPars)) { .ret$model$extra.pars <- eval(call(control$diagXform, .ret$model$extra.pars)) if (length(.ret$model$extra.pars) > 0) { inits$THTA <- c(inits$THTA, .ret$model$extra.pars) .lowerErr <- rep(control$atol[1] * 10, length(.ret$model$extra.pars)) .upperErr <- rep(Inf, length(.ret$model$extra.pars)) lower <- c(lower, .lowerErr) upper <- c(upper, .upperErr) } } if (is.null(data$ID)) stop("\"ID\" not found in data") if (is.null(data$DV)) stop("\"DV\" not found in data") if (is.null(data$EVID)) data$EVID <- 0 if (is.null(data$AMT)) data$AMT <- 0 for (.v in c("TIME", "AMT", "DV", .covNames)) { data[[.v]] <- as.double(data[[.v]]) } .ret$dataSav <- data .ds <- data[data$EVID != 0 & data$EVID != 2, c("ID", "TIME", "AMT", "EVID", .covNames)] .w <- which(tolower(names(data)) == "limit") .limitName <- NULL if (length(.w) == 1L) { .limitName <- names(data)[.w] } .censName <- NULL .w <- which(tolower(names(data)) == "cens") if (length(.w) == 1L) { .censName <- names(data[.w]) } data <- data[data$EVID == 0 | data$EVID == 2, c("ID", "TIME", "DV", "EVID", .covNames, .limitName, .censName)] .w <- which(!(names(.ret$dataSav) %in% c(.covNames, keep))) names(.ret$dataSav)[.w] <- tolower(names(.ret$dataSav[.w])) if (.mixed) { .lh <- .parseOM(inits$OMGA) .nlh <- sapply(.lh, length) .osplt <- rep(1:length(.lh), .nlh) .lini <- list(inits$THTA, unlist(.lh)) .nlini <- sapply(.lini, length) .nsplt <- rep(1:length(.lini), .nlini) .om0 <- .genOM(.lh) if (length(etaNames) == dim(.om0)[1]) { .ret$etaNames <- .ret$etaNames } else { .ret$etaNames <- sprintf("ETA[%d]", seq(1, dim(.om0)[1])) } .ret$rxInv <- RxODE::rxSymInvCholCreate(mat = .om0, diag.xform = control$diagXform) .ret$xType <- .ret$rxInv$xType .om0a <- .om0 .om0a <- .om0a/control$diagOmegaBoundLower .om0b <- .om0 .om0b <- .om0b * control$diagOmegaBoundUpper .om0a <- RxODE::rxSymInvCholCreate(mat = .om0a, diag.xform = control$diagXform) .om0b <- RxODE::rxSymInvCholCreate(mat = .om0b, diag.xform = control$diagXform) .omdf <- data.frame(a = .om0a$theta, m = .ret$rxInv$theta, b = .om0b$theta, diag = .om0a$theta.diag) .omdf$lower <- with(.omdf, ifelse(a > b, b, a)) .omdf$lower <- with(.omdf, ifelse(lower == m, -Inf, lower)) .omdf$lower <- with(.omdf, ifelse(!diag, -Inf, lower)) .omdf$upper <- with(.omdf, ifelse(a < b, b, a)) .omdf$upper <- with(.omdf, ifelse(upper == m, Inf, upper)) .omdf$upper <- with(.omdf, ifelse(!diag, Inf, upper)) .ret$control$nomega <- length(.omdf$lower) .ret$control$neta <- sum(.omdf$diag) .ret$control$ntheta <- length(lower) .ret$control$nfixed <- sum(fixed) lower <- c(lower, .omdf$lower) upper <- c(upper, .omdf$upper) } else { .ret$control$nomega <- 0 .ret$control$neta <- 0 .ret$xType <- -1 .ret$control$ntheta <- length(lower) .ret$control$nfixed <- sum(fixed) } .ret$lower <- lower .ret$upper <- upper .ret$thetaIni <- inits$THTA .scaleC <- double(length(lower)) if (is.null(control$scaleC)) { .scaleC <- rep(NA_real_, length(lower)) } else { .scaleC <- as.double(control$scaleC) if (length(lower) > length(.scaleC)) { .scaleC <- c(.scaleC, rep(NA_real_, length(lower) - length(.scaleC))) } else if (length(lower) < length(.scaleC)) { .scaleC <- .scaleC[seq(1, length(lower))] warning("scaleC control option has more options than estimated population parameters, please check.") } } .ret$scaleC <- .scaleC if (exists("uif", envir = .ret)) { .ini <- as.data.frame(.ret$uif$ini)[!is.na(.ret$uif$ini$err), c("est", "err", "ntheta")] for (.i in seq_along(.ini$err)) { if (is.na(.ret$scaleC[.ini$ntheta[.i]])) { if (any(.ini$err[.i] == c("boxCox", "yeoJohnson", "pow2", "tbs", "tbsYj"))) { .ret$scaleC[.ini$ntheta[.i]] <- 1 } else if (any(.ini$err[.i] == c("prop", "add", "norm", "dnorm", "logn", "dlogn", "lnorm", "dlnorm"))) { .ret$scaleC[.ini$ntheta[.i]] <- 0.5 * abs(.ini$est[.i]) } } } for (.i in .ini$model$extraProps$powTheta) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- 1 } .ini <- as.data.frame(.ret$uif$ini) for (.i in .ini$model$extraProps$factorial) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- abs(1/digamma(.ini$est[.i] + 1)) } for (.i in .ini$model$extraProps$gamma) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- abs(1/digamma(.ini$est[.i])) } for (.i in .ini$model$extraProps$log) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- log(abs(.ini$est[.i])) * abs(.ini$est[.i]) } for (.i in .ret$logitThetas) { .b <- .ret$logitThetasLow[.i] .c <- .ret$logitThetasHi[.i] .a <- .ini$est[.i] if (is.na(.ret$scaleC[.i])) { .ret$scaleC[.i] <- 1 * (-.b + .c) * exp(-.a)/((1 + exp(-.a))^2 * (.b + 1 * (-.b + .c)/(1 + exp(-.a)))) } } } names(.ret$thetaIni) <- sprintf("THETA[%d]", seq_along(.ret$thetaIni)) if (is.null(etaMat) & !is.null(control$etaMat)) { .ret$etaMat <- control$etaMat } else { .ret$etaMat <- etaMat } .ret$setupTime <- (proc.time() - .pt)["elapsed"] if (exists("uif", envir = .ret)) { .tmp <- .ret$uif$logThetasList .ret$logThetas <- .tmp[[1]] .ret$logThetasF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasList .ret$logitThetas <- .tmp[[1]] .ret$logitThetasF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasListLow .ret$logitThetasLow <- .tmp[[1]] .ret$logitThetasLowF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasListHi .ret$logitThetasHi <- .tmp[[1]] .ret$logitThetasHiF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasList .ret$probitThetas <- .tmp[[1]] .ret$probitThetasF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasListLow .ret$probitThetasLow <- .tmp[[1]] .ret$probitThetasLowF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasListHi .ret$probitThetasHi <- .tmp[[1]] .ret$probitThetasHiF <- .tmp[[2]] } else { .ret$logThetasF <- integer(0) .ret$logitThetasF <- integer(0) .ret$logitThetasHiF <- numeric(0) .ret$logitThetasLowF <- numeric(0) .ret$logitThetas <- integer(0) .ret$logitThetasHi <- numeric(0) .ret$logitThetasLow <- numeric(0) .ret$probitThetasF <- integer(0) .ret$probitThetasHiF <- numeric(0) .ret$probitThetasLowF <- numeric(0) .ret$probitThetas <- integer(0) .ret$probitThetasHi <- numeric(0) .ret$probitThetasLow <- numeric(0) } if (exists("noLik", envir = .ret)) { if (!.ret$noLik) { .ret$.params <- c(sprintf("THETA[%d]", seq_along(.ret$thetaIni)), sprintf("ETA[%d]", seq(1, dim(.om0)[1]))) .ret$.thetan <- length(.ret$thetaIni) .ret$nobs <- sum(data$EVID == 0) } } .ret$control$printTop <- TRUE .ret$control$nF <- 0 .est0 <- .ret$thetaIni if (!is.null(.ret$model$pred.nolhs)) { .ret$control$predNeq <- length(.ret$model$pred.nolhs$state) } else { .ret$control$predNeq <- 0L } .fitFun <- function(.ret) { this.env <- environment() assign("err", "theta reset", this.env) while (this.env$err == "theta reset") { assign("err", "", this.env) .ret0 <- tryCatch({ foceiFitCpp_(.ret) }, error = function(e) { if (regexpr("theta reset", e$message) != -1) { assign("zeroOuter", FALSE, this.env) assign("zeroGrad", FALSE, this.env) if (regexpr("theta reset0", e$message) != -1) { assign("zeroGrad", TRUE, this.env) } else if (regexpr("theta resetZ", e$message) != -1) { assign("zeroOuter", TRUE, this.env) } assign("err", "theta reset", this.env) } else { assign("err", e$message, this.env) } }) if (this.env$err == "theta reset") { .nm <- names(.ret$thetaIni) .ret$thetaIni <- setNames(.thetaReset$thetaIni + 0, .nm) .ret$rxInv$theta <- .thetaReset$omegaTheta .ret$control$printTop <- FALSE .ret$etaMat <- .thetaReset$etaMat .ret$control$etaMat <- .thetaReset$etaMat .ret$control$maxInnerIterations <- .thetaReset$maxInnerIterations .ret$control$nF <- .thetaReset$nF .ret$control$gillRetC <- .thetaReset$gillRetC .ret$control$gillRet <- .thetaReset$gillRet .ret$control$gillRet <- .thetaReset$gillRet .ret$control$gillDf <- .thetaReset$gillDf .ret$control$gillDf2 <- .thetaReset$gillDf2 .ret$control$gillErr <- .thetaReset$gillErr .ret$control$rEps <- .thetaReset$rEps .ret$control$aEps <- .thetaReset$aEps .ret$control$rEpsC <- .thetaReset$rEpsC .ret$control$aEpsC <- .thetaReset$aEpsC .ret$control$c1 <- .thetaReset$c1 .ret$control$c2 <- .thetaReset$c2 if (this.env$zeroOuter) { message("Posthoc reset") .ret$control$maxOuterIterations <- 0L } else if (this.env$zeroGrad) { message("Theta reset (zero gradient values); Switch to bobyqa") RxODE::rxReq("minqa") .ret$control$outerOptFun <- .bobyqa .ret$control$outerOpt <- -1L } else { message("Theta reset (ETA drift)") } } } if (this.env$err != "") { stop(this.env$err) } else { return(.ret0) } } .ret0 <- try(.fitFun(.ret)) .n <- 1 while (inherits(.ret0, "try-error") && control$maxOuterIterations != 0 && .n <= control$nRetries) { message(sprintf("Restart %s", .n)) .ret$control$nF <- 0 .estNew <- .est0 + 0.2 * .n * abs(.est0) * stats::runif(length(.est0)) - 0.1 * .n .estNew <- sapply(seq_along(.est0), function(.i) { if (.ret$thetaFixed[.i]) { return(.est0[.i]) } else if (.estNew[.i] < lower[.i]) { return(lower + (.Machine$double.eps)^(1/7)) } else if (.estNew[.i] > upper[.i]) { return(upper - (.Machine$double.eps)^(1/7)) } else { return(.estNew[.i]) } }) .ret$thetaIni <- .estNew .ret0 <- try(.fitFun(.ret)) .n <- .n + 1 } if (inherits(.ret0, "try-error")) stop("Could not fit data.") .ret <- .ret0 if (exists("parHistData", .ret)) { .tmp <- .ret$parHistData .tmp <- .tmp[.tmp$type == "Unscaled", names(.tmp) != "type"] .iter <- .tmp$iter .tmp <- .tmp[, names(.tmp) != "iter"] .ret$parHistStacked <- data.frame(stack(.tmp), iter = .iter) names(.ret$parHistStacked) <- c("val", "par", "iter") .ret$parHist <- data.frame(iter = .iter, .tmp) } if (.mixed) { .etas <- .ret$ranef .thetas <- .ret$fixef .pars <- .Call(`_nlmixr_nlmixrParameters`, .thetas, .etas) .ret$shrink <- .Call(`_nlmixr_calcShrinkOnly`, .ret$omega, .pars$eta.lst, length(.etas$ID)) .updateParFixed(.ret) } else { .updateParFixed(.ret) } if (!exists("table", .ret)) { .ret$table <- tableControl() } if (control$calcTables) { .ret <- addTable(.ret, updateObject = "no", keep = keep, drop = drop, table = .ret$table) } .ret})(data = dat, inits = .FoceiInits, PKpars = .pars, model = .mod, pred = function() { return(nlmixr_pred) }, err = uif$error, lower = uif$focei.lower, upper = uif$focei.upper, fixed = uif$focei.fixed, thetaNames = uif$focei.names, etaNames = uif$eta.names, control = control, env = env, keep = .keep, drop = .drop): Not all the covariates are in the dataset.</span></div><div class='output co'>#> <span class='message'>Timing stopped at: 8.173 0.386 8.556</span></div><div class='input'><span class='va'>f_nlmixr_dfop_sfo_saem_obs_tc</span> <span class='op'><-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr</a></span><span class='op'>(</span><span class='va'>f_mmkin_tc</span><span class='op'>[</span><span class='st'>"DFOP-SFO"</span>, <span class='op'>]</span>, est <span class='op'>=</span> <span class='st'>"saem"</span>,
error_model <span class='op'>=</span> <span class='st'>"obs_tc"</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> parameter labels from comments are typically ignored in non-interactive mode</span></div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> Need to run with the source intact to parse comments</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='error'>Error in configsaem(model = model, data = dat, inits = inits, mcmc = .mcmc, ODEopt = .ODEopt, seed = .seed, distribution = .dist, DEBUG = .DEBUG, addProp = .addProp, tol = .tol, itmax = .itmax, type = .type, powRange = .powRange, lambdaRange = .lambdaRange): covariate(s) not found: f_parent_to_A1</span></div><div class='output co'>#> <span class='message'>Timing stopped at: 0.799 0.044 0.842</span></div><div class='input'><span class='va'>f_nlmixr_dfop_sfo_focei_obs_tc</span> <span class='op'><-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlmixr/man/nlmixr.html'>nlmixr</a></span><span class='op'>(</span><span class='va'>f_mmkin_tc</span><span class='op'>[</span><span class='st'>"DFOP-SFO"</span>, <span class='op'>]</span>, est <span class='op'>=</span> <span class='st'>"focei"</span>,
error_model <span class='op'>=</span> <span class='st'>"obs_tc"</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> parameter labels from comments are typically ignored in non-interactive mode</span></div><div class='output co'>#> <span class='message'><span style='color: #00BBBB;'>ℹ</span> Need to run with the source intact to parse comments</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ creating full model...</span></div><div class='output co'>#> <span class='message'>→ pruning branches (<span style='color: #262626; background-color: #DADADA;'>`if`</span>/<span style='color: #262626; background-color: #DADADA;'>`else`</span>)...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ loading into <span style='color: #0000BB;'>symengine</span> environment...</span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ calculate jacobian</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate sensitivities</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(f)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ calculate ∂(R²)/∂(η)</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in inner model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in EBE model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling inner model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ finding duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ optimizing duplicate expressions in FD model...</span></div><div class='output co'>#> </div><div class='output co'>#> <span class='message'>→ compiling EBE model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>→ compiling events FD model...</span></div><div class='output co'>#> <span class='message'> </span></div><div class='output co'>#> <span class='message'><span style='color: #00BB00;'>✔</span> done</span></div><div class='output co'>#> <span class='message'>Model:</span></div><div class='output co'>#> <span class='message'>cmt(parent);</span>
#> <span class='message'>cmt(A1);</span>
#> <span class='message'>rx_expr_6~ETA[1]+THETA[1];</span>
#> <span class='message'>parent(0)=rx_expr_6;</span>
#> <span class='message'>rx_expr_7~ETA[4]+THETA[4];</span>
#> <span class='message'>rx_expr_8~ETA[6]+THETA[6];</span>
#> <span class='message'>rx_expr_9~ETA[5]+THETA[5];</span>
#> <span class='message'>rx_expr_12~exp(rx_expr_7);</span>
#> <span class='message'>rx_expr_13~exp(rx_expr_9);</span>
#> <span class='message'>rx_expr_15~t*rx_expr_12;</span>
#> <span class='message'>rx_expr_16~t*rx_expr_13;</span>
#> <span class='message'>rx_expr_17~exp(-(rx_expr_8));</span>
#> <span class='message'>rx_expr_19~1+rx_expr_17;</span>
#> <span class='message'>rx_expr_24~1/(rx_expr_19);</span>
#> <span class='message'>rx_expr_26~(rx_expr_24);</span>
#> <span class='message'>rx_expr_27~1-rx_expr_26;</span>
#> <span class='message'>d/dt(parent)=-parent*(exp(rx_expr_7-rx_expr_15)/(rx_expr_19)+exp(rx_expr_9-rx_expr_16)*(rx_expr_27))/(exp(-t*rx_expr_12)/(rx_expr_19)+exp(-t*rx_expr_13)*(rx_expr_27));</span>
#> <span class='message'>rx_expr_10~ETA[2]+THETA[2];</span>
#> <span class='message'>rx_expr_14~exp(rx_expr_10);</span>
#> <span class='message'>d/dt(A1)=-rx_expr_14*A1+parent*f_parent_to_A1*(exp(rx_expr_7-rx_expr_15)/(rx_expr_19)+exp(rx_expr_9-rx_expr_16)*(rx_expr_27))/(exp(-t*rx_expr_12)/(rx_expr_19)+exp(-t*rx_expr_13)*(rx_expr_27));</span>
#> <span class='message'>rx_expr_0~CMT==2;</span>
#> <span class='message'>rx_expr_1~CMT==1;</span>
#> <span class='message'>rx_expr_2~1-(rx_expr_0);</span>
#> <span class='message'>rx_yj_~2*(rx_expr_2)*(rx_expr_1)+2*(rx_expr_0);</span>
#> <span class='message'>rx_expr_3~(rx_expr_0);</span>
#> <span class='message'>rx_expr_5~(rx_expr_2);</span>
#> <span class='message'>rx_expr_18~rx_expr_5*(rx_expr_1);</span>
#> <span class='message'>rx_lambda_~rx_expr_18+rx_expr_3;</span>
#> <span class='message'>rx_hi_~rx_expr_18+rx_expr_3;</span>
#> <span class='message'>rx_low_~0;</span>
#> <span class='message'>rx_expr_4~A1*(rx_expr_0);</span>
#> <span class='message'>rx_expr_11~parent*(rx_expr_2);</span>
#> <span class='message'>rx_expr_22~rx_expr_11*(rx_expr_1);</span>
#> <span class='message'>rx_pred_=(rx_expr_4+rx_expr_22)*(rx_expr_0)+(rx_expr_4+rx_expr_22)*(rx_expr_2)*(rx_expr_1);</span>
#> <span class='message'>rx_r_=(rx_expr_0)*(Rx_pow_di(((rx_expr_4+rx_expr_22)*(rx_expr_0)+(rx_expr_4+rx_expr_22)*(rx_expr_2)*(rx_expr_1)),2)*Rx_pow_di(THETA[10],2)+Rx_pow_di(THETA[9],2))+(Rx_pow_di(THETA[8],2)*Rx_pow_di(((rx_expr_4+rx_expr_22)*(rx_expr_1)),2)+Rx_pow_di(THETA[7],2))*(rx_expr_2)*(rx_expr_1);</span>
#> <span class='message'>parent_0=THETA[1];</span>
#> <span class='message'>log_k_A1=THETA[2];</span>
#> <span class='message'>f_parent_qlogis=THETA[3];</span>
#> <span class='message'>log_k1=THETA[4];</span>
#> <span class='message'>log_k2=THETA[5];</span>
#> <span class='message'>g_qlogis=THETA[6];</span>
#> <span class='message'>sigma_low_parent=THETA[7];</span>
#> <span class='message'>rsd_high_parent=THETA[8];</span>
#> <span class='message'>sigma_low_A1=THETA[9];</span>
#> <span class='message'>rsd_high_A1=THETA[10];</span>
#> <span class='message'>eta.parent_0=ETA[1];</span>
#> <span class='message'>eta.log_k_A1=ETA[2];</span>
#> <span class='message'>eta.f_parent_qlogis=ETA[3];</span>
#> <span class='message'>eta.log_k1=ETA[4];</span>
#> <span class='message'>eta.log_k2=ETA[5];</span>
#> <span class='message'>eta.g_qlogis=ETA[6];</span>
#> <span class='message'>parent_0_model=rx_expr_6;</span>
#> <span class='message'>k_A1=rx_expr_14;</span>
#> <span class='message'>k1=rx_expr_12;</span>
#> <span class='message'>k2=rx_expr_13;</span>
#> <span class='message'>f_parent=1/(1+exp(-(ETA[3]+THETA[3])));</span>
#> <span class='message'>g=1/(rx_expr_19);</span>
#> <span class='message'>tad=tad();</span>
#> <span class='message'>dosenum=dosenum();</span></div><div class='output co'>#> <span class='message'>Needed Covariates:</span></div><div class='output co'>#> <span class='message'>[1] "f_parent_to_A1" "CMT" </span></div><div class='output co'>#> <span class='error'>Error in (function (data, inits, PKpars, model = NULL, pred = NULL, err = NULL, lower = -Inf, upper = Inf, fixed = NULL, skipCov = NULL, control = foceiControl(), thetaNames = NULL, etaNames = NULL, etaMat = NULL, ..., env = NULL, keep = NULL, drop = NULL) { set.seed(control$seed) .pt <- proc.time() RxODE::.setWarnIdSort(FALSE) on.exit(RxODE::.setWarnIdSort(TRUE)) loadNamespace("n1qn1") if (!RxODE::rxIs(control, "foceiControl")) { control <- do.call(foceiControl, control) } if (is.null(env)) { .ret <- new.env(parent = emptyenv()) } else { .ret <- env } .ret$origData <- data .ret$etaNames <- etaNames .ret$thetaFixed <- fixed .ret$control <- control .ret$control$focei.mu.ref <- integer(0) if (is(model, "RxODE") || is(model, "character")) { .ret$ODEmodel <- TRUE if (class(pred) != "function") { stop("pred must be a function specifying the prediction variables in this model.") } } else { .ret$ODEmodel <- TRUE model <- RxODE::rxGetLin(PKpars) pred <- eval(parse(text = "function(){return(Central);}")) } .square <- function(x) x * x .ret$diagXformInv <- c(sqrt = ".square", log = "exp", identity = "identity")[control$diagXform] if (is.null(err)) { err <- eval(parse(text = paste0("function(){err", paste(inits$ERROR[[1]], collapse = ""), "}"))) } .covNames <- .parNames <- c() .ret$adjLik <- control$adjLik .mixed <- !is.null(inits$OMGA) && length(inits$OMGA) > 0 if (!exists("noLik", envir = .ret)) { .atol <- rep(control$atol, length(RxODE::rxModelVars(model)$state)) .rtol <- rep(control$rtol, length(RxODE::rxModelVars(model)$state)) .ssAtol <- rep(control$ssAtol, length(RxODE::rxModelVars(model)$state)) .ssRtol <- rep(control$ssRtol, length(RxODE::rxModelVars(model)$state)) .ret$model <- RxODE::rxSymPySetupPred(model, pred, PKpars, err, grad = (control$derivMethod == 2L), pred.minus.dv = TRUE, sum.prod = control$sumProd, theta.derivs = FALSE, optExpression = control$optExpression, interaction = (control$interaction == 1L), only.numeric = !.mixed, run.internal = TRUE, addProp = control$addProp) if (!is.null(.ret$model$inner)) { .atol <- c(.atol, rep(control$atolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.atol))) .rtol <- c(.rtol, rep(control$rtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.rtol))) .ret$control$rxControl$atol <- .atol .ret$control$rxControl$rtol <- .rtol .ssAtol <- c(.ssAtol, rep(control$ssAtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.ssAtol))) .ssRtol <- c(.ssRtol, rep(control$ssRtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.ssRtol))) .ret$control$rxControl$ssAtol <- .ssAtol .ret$control$rxControl$ssRtol <- .ssRtol } .covNames <- .parNames <- RxODE::rxParams(.ret$model$pred.only) .covNames <- .covNames[regexpr(rex::rex(start, or("THETA", "ETA"), "[", numbers, "]", end), .covNames) == -1] colnames(data) <- sapply(names(data), function(x) { if (any(x == .covNames)) { return(x) } else { return(toupper(x)) } }) .lhs <- c(names(RxODE::rxInits(.ret$model$pred.only)), RxODE::rxLhs(.ret$model$pred.only)) if (length(.lhs) > 0) { .covNames <- .covNames[regexpr(rex::rex(start, or(.lhs), end), .covNames) == -1] } if (length(.covNames) > 0) { if (!all(.covNames %in% names(data))) { message("Model:") RxODE::rxCat(.ret$model$pred.only) message("Needed Covariates:") nlmixrPrint(.covNames) stop("Not all the covariates are in the dataset.") } message("Needed Covariates:") print(.covNames) } .extraPars <- .ret$model$extra.pars } else { if (.ret$noLik) { .atol <- rep(control$atol, length(RxODE::rxModelVars(model)$state)) .rtol <- rep(control$rtol, length(RxODE::rxModelVars(model)$state)) .ret$model <- RxODE::rxSymPySetupPred(model, pred, PKpars, err, grad = FALSE, pred.minus.dv = TRUE, sum.prod = control$sumProd, theta.derivs = FALSE, optExpression = control$optExpression, run.internal = TRUE, only.numeric = TRUE, addProp = control$addProp) if (!is.null(.ret$model$inner)) { .atol <- c(.atol, rep(control$atolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.atol))) .rtol <- c(.rtol, rep(control$rtolSens, length(RxODE::rxModelVars(.ret$model$inner)$state) - length(.rtol))) .ret$control$rxControl$atol <- .atol .ret$control$rxControl$rtol <- .rtol } .covNames <- .parNames <- RxODE::rxParams(.ret$model$pred.only) .covNames <- .covNames[regexpr(rex::rex(start, or("THETA", "ETA"), "[", numbers, "]", end), .covNames) == -1] colnames(data) <- sapply(names(data), function(x) { if (any(x == .covNames)) { return(x) } else { return(toupper(x)) } }) .lhs <- c(names(RxODE::rxInits(.ret$model$pred.only)), RxODE::rxLhs(.ret$model$pred.only)) if (length(.lhs) > 0) { .covNames <- .covNames[regexpr(rex::rex(start, or(.lhs), end), .covNames) == -1] } if (length(.covNames) > 0) { if (!all(.covNames %in% names(data))) { message("Model:") RxODE::rxCat(.ret$model$pred.only) message("Needed Covariates:") nlmixrPrint(.covNames) stop("Not all the covariates are in the dataset.") } message("Needed Covariates:") print(.covNames) } .extraPars <- .ret$model$extra.pars } else { .extraPars <- NULL } } .ret$skipCov <- skipCov if (is.null(skipCov)) { if (is.null(fixed)) { .tmp <- rep(FALSE, length(inits$THTA)) } else { if (length(fixed) < length(inits$THTA)) { .tmp <- c(fixed, rep(FALSE, length(inits$THTA) - length(fixed))) } else { .tmp <- fixed[1:length(inits$THTA)] } } if (exists("uif", envir = .ret)) { .uifErr <- .ret$uif$ini$err[!is.na(.ret$uif$ini$ntheta)] .uifErr <- sapply(.uifErr, function(x) { if (is.na(x)) { return(FALSE) } return(!any(x == c("pow2", "tbs", "tbsYj"))) }) .tmp <- (.tmp | .uifErr) } .ret$skipCov <- c(.tmp, rep(TRUE, length(.extraPars))) .ret$control$focei.mu.ref <- .ret$uif$focei.mu.ref } if (is.null(.extraPars)) { .nms <- c(sprintf("THETA[%s]", seq_along(inits$THTA))) } else { .nms <- c(sprintf("THETA[%s]", seq_along(inits$THTA)), sprintf("ERR[%s]", seq_along(.extraPars))) } if (!is.null(thetaNames) && (length(inits$THTA) + length(.extraPars)) == length(thetaNames)) { .nms <- thetaNames } .ret$thetaNames <- .nms .thetaReset$thetaNames <- .nms if (length(lower) == 1) { lower <- rep(lower, length(inits$THTA)) } else if (length(lower) != length(inits$THTA)) { print(inits$THTA) print(lower) stop("Lower must be a single constant for all the THETA lower bounds, or match the dimension of THETA.") } if (length(upper) == 1) { upper <- rep(upper, length(inits$THTA)) } else if (length(lower) != length(inits$THTA)) { stop("Upper must be a single constant for all the THETA lower bounds, or match the dimension of THETA.") } if (!is.null(.extraPars)) { .ret$model$extra.pars <- eval(call(control$diagXform, .ret$model$extra.pars)) if (length(.ret$model$extra.pars) > 0) { inits$THTA <- c(inits$THTA, .ret$model$extra.pars) .lowerErr <- rep(control$atol[1] * 10, length(.ret$model$extra.pars)) .upperErr <- rep(Inf, length(.ret$model$extra.pars)) lower <- c(lower, .lowerErr) upper <- c(upper, .upperErr) } } if (is.null(data$ID)) stop("\"ID\" not found in data") if (is.null(data$DV)) stop("\"DV\" not found in data") if (is.null(data$EVID)) data$EVID <- 0 if (is.null(data$AMT)) data$AMT <- 0 for (.v in c("TIME", "AMT", "DV", .covNames)) { data[[.v]] <- as.double(data[[.v]]) } .ret$dataSav <- data .ds <- data[data$EVID != 0 & data$EVID != 2, c("ID", "TIME", "AMT", "EVID", .covNames)] .w <- which(tolower(names(data)) == "limit") .limitName <- NULL if (length(.w) == 1L) { .limitName <- names(data)[.w] } .censName <- NULL .w <- which(tolower(names(data)) == "cens") if (length(.w) == 1L) { .censName <- names(data[.w]) } data <- data[data$EVID == 0 | data$EVID == 2, c("ID", "TIME", "DV", "EVID", .covNames, .limitName, .censName)] .w <- which(!(names(.ret$dataSav) %in% c(.covNames, keep))) names(.ret$dataSav)[.w] <- tolower(names(.ret$dataSav[.w])) if (.mixed) { .lh <- .parseOM(inits$OMGA) .nlh <- sapply(.lh, length) .osplt <- rep(1:length(.lh), .nlh) .lini <- list(inits$THTA, unlist(.lh)) .nlini <- sapply(.lini, length) .nsplt <- rep(1:length(.lini), .nlini) .om0 <- .genOM(.lh) if (length(etaNames) == dim(.om0)[1]) { .ret$etaNames <- .ret$etaNames } else { .ret$etaNames <- sprintf("ETA[%d]", seq(1, dim(.om0)[1])) } .ret$rxInv <- RxODE::rxSymInvCholCreate(mat = .om0, diag.xform = control$diagXform) .ret$xType <- .ret$rxInv$xType .om0a <- .om0 .om0a <- .om0a/control$diagOmegaBoundLower .om0b <- .om0 .om0b <- .om0b * control$diagOmegaBoundUpper .om0a <- RxODE::rxSymInvCholCreate(mat = .om0a, diag.xform = control$diagXform) .om0b <- RxODE::rxSymInvCholCreate(mat = .om0b, diag.xform = control$diagXform) .omdf <- data.frame(a = .om0a$theta, m = .ret$rxInv$theta, b = .om0b$theta, diag = .om0a$theta.diag) .omdf$lower <- with(.omdf, ifelse(a > b, b, a)) .omdf$lower <- with(.omdf, ifelse(lower == m, -Inf, lower)) .omdf$lower <- with(.omdf, ifelse(!diag, -Inf, lower)) .omdf$upper <- with(.omdf, ifelse(a < b, b, a)) .omdf$upper <- with(.omdf, ifelse(upper == m, Inf, upper)) .omdf$upper <- with(.omdf, ifelse(!diag, Inf, upper)) .ret$control$nomega <- length(.omdf$lower) .ret$control$neta <- sum(.omdf$diag) .ret$control$ntheta <- length(lower) .ret$control$nfixed <- sum(fixed) lower <- c(lower, .omdf$lower) upper <- c(upper, .omdf$upper) } else { .ret$control$nomega <- 0 .ret$control$neta <- 0 .ret$xType <- -1 .ret$control$ntheta <- length(lower) .ret$control$nfixed <- sum(fixed) } .ret$lower <- lower .ret$upper <- upper .ret$thetaIni <- inits$THTA .scaleC <- double(length(lower)) if (is.null(control$scaleC)) { .scaleC <- rep(NA_real_, length(lower)) } else { .scaleC <- as.double(control$scaleC) if (length(lower) > length(.scaleC)) { .scaleC <- c(.scaleC, rep(NA_real_, length(lower) - length(.scaleC))) } else if (length(lower) < length(.scaleC)) { .scaleC <- .scaleC[seq(1, length(lower))] warning("scaleC control option has more options than estimated population parameters, please check.") } } .ret$scaleC <- .scaleC if (exists("uif", envir = .ret)) { .ini <- as.data.frame(.ret$uif$ini)[!is.na(.ret$uif$ini$err), c("est", "err", "ntheta")] for (.i in seq_along(.ini$err)) { if (is.na(.ret$scaleC[.ini$ntheta[.i]])) { if (any(.ini$err[.i] == c("boxCox", "yeoJohnson", "pow2", "tbs", "tbsYj"))) { .ret$scaleC[.ini$ntheta[.i]] <- 1 } else if (any(.ini$err[.i] == c("prop", "add", "norm", "dnorm", "logn", "dlogn", "lnorm", "dlnorm"))) { .ret$scaleC[.ini$ntheta[.i]] <- 0.5 * abs(.ini$est[.i]) } } } for (.i in .ini$model$extraProps$powTheta) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- 1 } .ini <- as.data.frame(.ret$uif$ini) for (.i in .ini$model$extraProps$factorial) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- abs(1/digamma(.ini$est[.i] + 1)) } for (.i in .ini$model$extraProps$gamma) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- abs(1/digamma(.ini$est[.i])) } for (.i in .ini$model$extraProps$log) { if (is.na(.ret$scaleC[.i])) .ret$scaleC[.i] <- log(abs(.ini$est[.i])) * abs(.ini$est[.i]) } for (.i in .ret$logitThetas) { .b <- .ret$logitThetasLow[.i] .c <- .ret$logitThetasHi[.i] .a <- .ini$est[.i] if (is.na(.ret$scaleC[.i])) { .ret$scaleC[.i] <- 1 * (-.b + .c) * exp(-.a)/((1 + exp(-.a))^2 * (.b + 1 * (-.b + .c)/(1 + exp(-.a)))) } } } names(.ret$thetaIni) <- sprintf("THETA[%d]", seq_along(.ret$thetaIni)) if (is.null(etaMat) & !is.null(control$etaMat)) { .ret$etaMat <- control$etaMat } else { .ret$etaMat <- etaMat } .ret$setupTime <- (proc.time() - .pt)["elapsed"] if (exists("uif", envir = .ret)) { .tmp <- .ret$uif$logThetasList .ret$logThetas <- .tmp[[1]] .ret$logThetasF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasList .ret$logitThetas <- .tmp[[1]] .ret$logitThetasF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasListLow .ret$logitThetasLow <- .tmp[[1]] .ret$logitThetasLowF <- .tmp[[2]] .tmp <- .ret$uif$logitThetasListHi .ret$logitThetasHi <- .tmp[[1]] .ret$logitThetasHiF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasList .ret$probitThetas <- .tmp[[1]] .ret$probitThetasF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasListLow .ret$probitThetasLow <- .tmp[[1]] .ret$probitThetasLowF <- .tmp[[2]] .tmp <- .ret$uif$probitThetasListHi .ret$probitThetasHi <- .tmp[[1]] .ret$probitThetasHiF <- .tmp[[2]] } else { .ret$logThetasF <- integer(0) .ret$logitThetasF <- integer(0) .ret$logitThetasHiF <- numeric(0) .ret$logitThetasLowF <- numeric(0) .ret$logitThetas <- integer(0) .ret$logitThetasHi <- numeric(0) .ret$logitThetasLow <- numeric(0) .ret$probitThetasF <- integer(0) .ret$probitThetasHiF <- numeric(0) .ret$probitThetasLowF <- numeric(0) .ret$probitThetas <- integer(0) .ret$probitThetasHi <- numeric(0) .ret$probitThetasLow <- numeric(0) } if (exists("noLik", envir = .ret)) { if (!.ret$noLik) { .ret$.params <- c(sprintf("THETA[%d]", seq_along(.ret$thetaIni)), sprintf("ETA[%d]", seq(1, dim(.om0)[1]))) .ret$.thetan <- length(.ret$thetaIni) .ret$nobs <- sum(data$EVID == 0) } } .ret$control$printTop <- TRUE .ret$control$nF <- 0 .est0 <- .ret$thetaIni if (!is.null(.ret$model$pred.nolhs)) { .ret$control$predNeq <- length(.ret$model$pred.nolhs$state) } else { .ret$control$predNeq <- 0L } .fitFun <- function(.ret) { this.env <- environment() assign("err", "theta reset", this.env) while (this.env$err == "theta reset") { assign("err", "", this.env) .ret0 <- tryCatch({ foceiFitCpp_(.ret) }, error = function(e) { if (regexpr("theta reset", e$message) != -1) { assign("zeroOuter", FALSE, this.env) assign("zeroGrad", FALSE, this.env) if (regexpr("theta reset0", e$message) != -1) { assign("zeroGrad", TRUE, this.env) } else if (regexpr("theta resetZ", e$message) != -1) { assign("zeroOuter", TRUE, this.env) } assign("err", "theta reset", this.env) } else { assign("err", e$message, this.env) } }) if (this.env$err == "theta reset") { .nm <- names(.ret$thetaIni) .ret$thetaIni <- setNames(.thetaReset$thetaIni + 0, .nm) .ret$rxInv$theta <- .thetaReset$omegaTheta .ret$control$printTop <- FALSE .ret$etaMat <- .thetaReset$etaMat .ret$control$etaMat <- .thetaReset$etaMat .ret$control$maxInnerIterations <- .thetaReset$maxInnerIterations .ret$control$nF <- .thetaReset$nF .ret$control$gillRetC <- .thetaReset$gillRetC .ret$control$gillRet <- .thetaReset$gillRet .ret$control$gillRet <- .thetaReset$gillRet .ret$control$gillDf <- .thetaReset$gillDf .ret$control$gillDf2 <- .thetaReset$gillDf2 .ret$control$gillErr <- .thetaReset$gillErr .ret$control$rEps <- .thetaReset$rEps .ret$control$aEps <- .thetaReset$aEps .ret$control$rEpsC <- .thetaReset$rEpsC .ret$control$aEpsC <- .thetaReset$aEpsC .ret$control$c1 <- .thetaReset$c1 .ret$control$c2 <- .thetaReset$c2 if (this.env$zeroOuter) { message("Posthoc reset") .ret$control$maxOuterIterations <- 0L } else if (this.env$zeroGrad) { message("Theta reset (zero gradient values); Switch to bobyqa") RxODE::rxReq("minqa") .ret$control$outerOptFun <- .bobyqa .ret$control$outerOpt <- -1L } else { message("Theta reset (ETA drift)") } } } if (this.env$err != "") { stop(this.env$err) } else { return(.ret0) } } .ret0 <- try(.fitFun(.ret)) .n <- 1 while (inherits(.ret0, "try-error") && control$maxOuterIterations != 0 && .n <= control$nRetries) { message(sprintf("Restart %s", .n)) .ret$control$nF <- 0 .estNew <- .est0 + 0.2 * .n * abs(.est0) * stats::runif(length(.est0)) - 0.1 * .n .estNew <- sapply(seq_along(.est0), function(.i) { if (.ret$thetaFixed[.i]) { return(.est0[.i]) } else if (.estNew[.i] < lower[.i]) { return(lower + (.Machine$double.eps)^(1/7)) } else if (.estNew[.i] > upper[.i]) { return(upper - (.Machine$double.eps)^(1/7)) } else { return(.estNew[.i]) } }) .ret$thetaIni <- .estNew .ret0 <- try(.fitFun(.ret)) .n <- .n + 1 } if (inherits(.ret0, "try-error")) stop("Could not fit data.") .ret <- .ret0 if (exists("parHistData", .ret)) { .tmp <- .ret$parHistData .tmp <- .tmp[.tmp$type == "Unscaled", names(.tmp) != "type"] .iter <- .tmp$iter .tmp <- .tmp[, names(.tmp) != "iter"] .ret$parHistStacked <- data.frame(stack(.tmp), iter = .iter) names(.ret$parHistStacked) <- c("val", "par", "iter") .ret$parHist <- data.frame(iter = .iter, .tmp) } if (.mixed) { .etas <- .ret$ranef .thetas <- .ret$fixef .pars <- .Call(`_nlmixr_nlmixrParameters`, .thetas, .etas) .ret$shrink <- .Call(`_nlmixr_calcShrinkOnly`, .ret$omega, .pars$eta.lst, length(.etas$ID)) .updateParFixed(.ret) } else { .updateParFixed(.ret) } if (!exists("table", .ret)) { .ret$table <- tableControl() } if (control$calcTables) { .ret <- addTable(.ret, updateObject = "no", keep = keep, drop = drop, table = .ret$table) } .ret})(data = dat, inits = .FoceiInits, PKpars = .pars, model = .mod, pred = function() { return(nlmixr_pred) }, err = uif$error, lower = uif$focei.lower, upper = uif$focei.upper, fixed = uif$focei.fixed, thetaNames = uif$focei.names, etaNames = uif$eta.names, control = control, env = env, keep = .keep, drop = .drop): Not all the covariates are in the dataset.</span></div><div class='output co'>#> <span class='message'>Timing stopped at: 17.5 0.646 18.15</span></div><div class='input'>
<span class='fu'><a href='https://rdrr.io/r/stats/AIC.html'>AIC</a></span><span class='op'>(</span>
<span class='va'>f_nlmixr_sfo_sfo_focei_const</span><span class='op'>$</span><span class='va'>nm</span>,
<span class='va'>f_nlmixr_fomc_sfo_focei_const</span><span class='op'>$</span><span class='va'>nm</span>,
<span class='va'>f_nlmixr_dfop_sfo_focei_const</span><span class='op'>$</span><span class='va'>nm</span>,
<span class='va'>f_nlmixr_fomc_sfo_saem_obs</span><span class='op'>$</span><span class='va'>nm</span>,
<span class='va'>f_nlmixr_fomc_sfo_focei_obs</span><span class='op'>$</span><span class='va'>nm</span>,
<span class='va'>f_nlmixr_dfop_sfo_saem_obs</span><span class='op'>$</span><span class='va'>nm</span>,
<span class='va'>f_nlmixr_dfop_sfo_focei_obs</span><span class='op'>$</span><span class='va'>nm</span>,
<span class='va'>f_nlmixr_fomc_sfo_focei_tc</span><span class='op'>$</span><span class='va'>nm</span>,
<span class='va'>f_nlmixr_dfop_sfo_focei_tc</span><span class='op'>$</span><span class='va'>nm</span>,
<span class='va'>f_nlmixr_fomc_sfo_saem_obs_tc</span><span class='op'>$</span><span class='va'>nm</span>,
<span class='va'>f_nlmixr_fomc_sfo_focei_obs_tc</span><span class='op'>$</span><span class='va'>nm</span>,
<span class='va'>f_nlmixr_dfop_sfo_saem_obs_tc</span><span class='op'>$</span><span class='va'>nm</span>,
<span class='va'>f_nlmixr_dfop_sfo_focei_obs_tc</span><span class='op'>$</span><span class='va'>nm</span>
<span class='op'>)</span>
</div><div class='output co'>#> <span class='error'>Error in AIC(f_nlmixr_sfo_sfo_focei_const$nm, f_nlmixr_fomc_sfo_focei_const$nm, f_nlmixr_dfop_sfo_focei_const$nm, f_nlmixr_fomc_sfo_saem_obs$nm, f_nlmixr_fomc_sfo_focei_obs$nm, f_nlmixr_dfop_sfo_saem_obs$nm, f_nlmixr_dfop_sfo_focei_obs$nm, f_nlmixr_fomc_sfo_focei_tc$nm, f_nlmixr_dfop_sfo_focei_tc$nm, f_nlmixr_fomc_sfo_saem_obs_tc$nm, f_nlmixr_fomc_sfo_focei_obs_tc$nm, f_nlmixr_dfop_sfo_saem_obs_tc$nm, f_nlmixr_dfop_sfo_focei_obs_tc$nm): object 'f_nlmixr_sfo_sfo_focei_const' not found</span></div><div class='input'><span class='co'># Currently, FOMC-SFO with two-component error by variable fitted by focei gives the</span>
<span class='co'># lowest AIC</span>
<span class='fu'><a href='https://rdrr.io/r/graphics/plot.default.html'>plot</a></span><span class='op'>(</span><span class='va'>f_nlmixr_fomc_sfo_focei_obs_tc</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='error'>Error in plot(f_nlmixr_fomc_sfo_focei_obs_tc): object 'f_nlmixr_fomc_sfo_focei_obs_tc' not found</span></div><div class='input'><span class='fu'><a href='https://rdrr.io/r/base/summary.html'>summary</a></span><span class='op'>(</span><span class='va'>f_nlmixr_fomc_sfo_focei_obs_tc</span><span class='op'>)</span>
</div><div class='output co'>#> <span class='error'>Error in summary(f_nlmixr_fomc_sfo_focei_obs_tc): object 'f_nlmixr_fomc_sfo_focei_obs_tc' not found</span></div><div class='input'><span class='co'># }</span>
</div></pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
<nav id="toc" data-toggle="toc" class="sticky-top">
<h2 data-toc-skip>Contents</h2>
</nav>
</div>
</div>
<footer>
<div class="copyright">
<p>Developed by Johannes Ranke.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.6.1.</p>
</div>
</footer>
</div>
</body>
</html>
|