summaryrefslogtreecommitdiff
path: root/docs/reference/one_box.md
blob: f956b8f0f52b259d7f6ab9ca6c7d4f222c53f25e (plain) (blame)
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
# Create a time series of decline data

Create a time series of decline data

## Usage

``` r
one_box(x, ini, ..., t_end = 100, res = 0.01)

# S3 method for class 'numeric'
one_box(x, ini = 1, ..., t_end = 100, res = 0.01)

# S3 method for class 'character'
one_box(x, ini = 1, parms, ..., t_end = 100, res = 0.01)

# S3 method for class 'mkinmod'
one_box(
  x,
  ini = c(1, rep(0, length(x$diffs) - 1)),
  odeparms,
  solution_type = "deSolve",
  ...,
  t_end = 100,
  res = 0.01
)

# S3 method for class 'mkinfit'
one_box(x, ini = "model", ..., t_end = 100, res = 0.01)
```

## Arguments

- x:

  When numeric, this is the half-life to be used for an exponential
  decline. When a character string specifying a parent decline model is
  given e.g. `FOMC`, `parms` must contain the corresponding parameters.
  If x is an
  [mkinfit](https://pkgdown.jrwb.de/mkin/reference/mkinfit.html) object,
  the decline is calculated from this object.

- ini:

  The initial amount. If x is an
  [mkinfit](https://pkgdown.jrwb.de/mkin/reference/mkinfit.html) object,
  and ini is 'model', the fitted initial concentrations are used.
  Otherwise, ini must be numeric. If it has length one, it is used for
  the parent and initial values of metabolites are zero, otherwise, it
  must give values for all observed variables.

- ...:

  Further arguments passed to methods

- t_end:

  End of the time series

- res:

  Resolution of the time series

- parms:

  A named numeric vector containing the model parameters

- odeparms:

  Will be passed to
  [mkinpredict](https://pkgdown.jrwb.de/mkin/reference/mkinpredict.html)

- solution_type:

  Will be passed to
  [mkinpredict](https://pkgdown.jrwb.de/mkin/reference/mkinpredict.html)

## Value

An object of class `one_box`, inheriting from
[ts](https://rdrr.io/r/stats/ts.html).

## Examples

``` r
# Only use a half-life
pred_0 <- one_box(10)
plot(pred_0)


# Use a fitted mkinfit model
require(mkin)
fit <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE)
pred_1 <- one_box(fit)
plot(pred_1)


# Use a model with more than one observed variable
m_2 <- mkinmod(parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"))
#> Temporary DLL for differentials generated and loaded
fit_2 <- mkinfit(m_2, FOCUS_2006_D, quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
pred_2 <- one_box(fit_2, ini = "model")
plot(pred_2)

library(mkin)
SFO_SFO <- mkinmod(
  parent = mkinsub("SFO", to = "m1"),
  m1 = mkinsub("SFO"))
#> Temporary DLL for differentials generated and loaded
c_0 = c(parent = 100, m1 = 0)
deg_parms = c(k_parent = 0.15, f_parent_to_m1 = 0.5, k_m1 = 0.01)
sfo_sfo_box <- one_box(SFO_SFO, odeparms = deg_parms, ini = c_0)
head(sfo_sfo_box)
#> Time Series:
#> Start = c(0, 1) 
#> End = c(0, 6) 
#> Frequency = 100 
#>         parent         m1
#> 0.00 100.00000 0.00000000
#> 0.01  99.85011 0.07494003
#> 0.02  99.70045 0.14976024
#> 0.03  99.55101 0.22446081
#> 0.04  99.40180 0.29904192
#> 0.05  99.25281 0.37350376
```

Contact - Imprint