Skip to contents

Constructs a data frame of starting values and parameter bounds for the Emax NLS optimisation, using heuristics derived from the data.

Usage

emax_nls_init(structural_model, covariate_model = NULL, data)

Arguments

structural_model

A two-sided formula of the form response ~ exposure

covariate_model

A list of two-sided formulas, each specifying a covariate model for a structural parameter. When NULL (the default), an intercept-only hyperbolic Emax model is assumed — equivalent to list(E0 ~ 1, Emax ~ 1, logEC50 ~ 1).

data

A data frame

Value

A data frame

Details

The emax_nls() function requires that the user specify the initial values for the model parameters. Specifically, it expects to be supplied with a data frame with columns named parameter, covariate, and start. If a bounded optimisation method is used (e.g. if the "port" method is used), the data frame also needs to have columns named lower and upper. The data frame should contain one row per parameter. In most cases the user does not need to define this manually, because emax_nls_init() can use heuristics to make a sensible guess about what to use as starting values. By default this is what emax_nls() relies upon, automatically calling emax_nls_init() using the appropriate values for the structural_model, the covariate_model, and the data.

Examples

# intercept-only hyperbolic Emax (default covariate_model)
emax_nls_init(
  structural_model = rsp_1 ~ exp_1,
  data = emax_df
)
#> # A tibble: 3 × 5
#>   parameter covariate start  lower upper
#>   <chr>     <chr>     <dbl>  <dbl> <dbl>
#> 1 E0        Intercept  9.73  0.528  18.9
#> 2 Emax      Intercept  7.74 -1.47   16.9
#> 3 logEC50   Intercept  8.69  6.63   10.8

# with a covariate on E0
emax_nls_init(
  structural_model = rsp_1 ~ exp_1, 
  covariate_model = list(E0 ~ cnt_a, Emax ~ 1, logEC50 ~ 1), 
  data = emax_df
)
#> # A tibble: 4 × 5
#>   parameter covariate start  lower upper
#>   <chr>     <chr>     <dbl>  <dbl> <dbl>
#> 1 E0        cnt_a      0    -7.84   7.84
#> 2 E0        Intercept  9.73  0.528 18.9 
#> 3 Emax      Intercept  7.74 -1.47  16.9 
#> 4 logEC50   Intercept  8.69  6.63  10.8 

# compare to the values estimated:
coef(emax_nls(
  structural_model = rsp_1 ~ exp_1, 
  covariate_model = list(E0 ~ cnt_a, Emax ~ 1, logEC50 ~ 1), 
  data = emax_df,
  opts = emax_nls_options(max_time = 10)
))
#>          E0_cnt_a      E0_Intercept    Emax_Intercept logEC50_Intercept 
#>         0.4861467         5.0548075         9.9697250         8.2688405