summaryrefslogtreecommitdiff
path: root/docs/reference/sawtooth.md
blob: 4d1c9e12189d7d0dfe82df9a9f74da91bf377e13 (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
# Create decline time series for multiple applications

If the application pattern is specified in `applications`, `n` and `i`
are disregarded.

## Usage

``` r
sawtooth(
  x,
  n = 1,
  i = 365,
  applications = data.frame(time = seq(0, (n - 1) * i, length.out = n), amount = 1)
)
```

## Arguments

- x:

  A [one_box](https://pkgdown.jrwb.de/pfm/reference/one_box.md) object

- n:

  The number of applications. If `applications` is specified, `n` is
  ignored

- i:

  The interval between applications. If `applications` is specified, `i`
  is ignored

- applications:

  A data frame holding the application times in the first column and the
  corresponding amounts applied in the second column.

## Examples

``` r
applications = data.frame(time = seq(0, 14, by = 7), amount = c(1, 2, 3))
pred <- one_box(10)
plot(sawtooth(pred, applications = applications))


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 = 1)
pred_2_saw <- sawtooth(pred_2, 2, 7)
plot(pred_2_saw, max_twa = 21, max_twa_var = "m1")



max_twa(pred_2_saw)
#> $max
#>    parent        m1 
#> 0.7834481 0.8617049 
#> 
#> $window_start
#> parent     m1 
#>   0.00  26.85 
#> 
#> $window_end
#> parent     m1 
#>  21.00  47.85 
#> 
```

Contact - Imprint