# doubleLogis

## 1. Package loading

    library(phenolocrop)
    #> Package phenolocrop is designed for scientific use.
    #> Use for commercial purposes shall not be allowed.
    #> Copyright (C) 2023 The National Agriculture and Food Research Organization. All rights reserved.

## 2. Data

The data frame should include the columns of the objective trait and time point. In the example rice CIg data, date column is for the measuring date, id is for the cultivar id, and x is for the days after sowing. The following CIg time-series data was generated by the computer simulation.

    riceCIg_eg
    #>          date        CIg        id   x
    #> 1  2022-05-16 0.03717737 cultivar1   1
    #> 2  2022-05-23 0.20980523 cultivar1   8
    #> 3  2022-05-30 0.69738409 cultivar1  15
    #> 4  2022-06-06 0.37060131 cultivar1  22
    #> 5  2022-06-13 1.18561345 cultivar1  29
    #> 6  2022-06-20 2.80843500 cultivar1  36
    #> 7  2022-06-27 4.55109738 cultivar1  43
    #> 8  2022-07-04 6.00841031 cultivar1  50
    #> 9  2022-07-11 6.79919311 cultivar1  57
    #> 10 2022-07-18 7.01819084 cultivar1  64
    #> 11 2022-07-25 6.68987496 cultivar1  71
    #> 12 2022-08-01 7.16579565 cultivar1  78
    #> 13 2022-08-08 7.18585993 cultivar1  85
    #> 14 2022-08-15 5.99292270 cultivar1  92
    #> 15 2022-08-22 5.71302032 cultivar1  99
    #> 16 2022-08-29 5.61173978 cultivar1 106
    #> 17 2022-09-05 4.44723896 cultivar1 113
    #> 18 2022-09-12 4.01720698 cultivar1 120
    #> 19 2022-09-19 3.48461195 cultivar1 127
    #> 20 2022-09-26 2.30159727 cultivar1 134
    #> 21 2022-10-03 2.27427143 cultivar1 141
    #> 22 2022-10-10 2.04049750 cultivar1 148

## 3. Estimate model parameters

    riceCIg_eg |>
      doubleLogis("x", "CIg")
    #>           r2           r3           d2           d3         ymax
    #>   0.15544198   0.05715089  38.85827904 125.33099354   7.18585993

## 4. Plot time-series model and measured CH data

    x_vec <- 1:max(riceCIg_eg$x)
    y <- riceCIg_eg |>
      doubleLogis("x", "CIg") |>
      phenololine(x = x_vec, method = "doubleLogis")
    plot(x_vec, y, type = "l", ylab = "rice CIg",
         xlab = "Dayes after sowing", ylim = range(riceCIg_eg$CIg))
    points(riceCIg_eg$x, riceCIg_eg$CIg)

## 5. Time-series model

Time-series model of `doubleLogis` for the rice CIg is as the following.

\[ \mathrm{CIg}=y_{max}\left( \frac{1}{1+\mathrm{exp}(r_2(d_2 - x))}- \frac{1}{1+\mathrm{exp}(r_3(d_3 - x))} \right) \]

## 6. Reference

S. Taniguchi et al. (2025) Phenology analysis for trait prediction using UAVs in a MAGIC rice population with different transplanting protocols. Frontiers in Artificial Intelligence, 7, 1477637.