Skip to contents

Ease of use wrapper function for fitting various growth models specified by growthSS

Usage

fitGrowth(ss, ...)

Arguments

ss

A list generated by growthSS.

...

Additional arguments passed to model fitting functions determined by ss$type. For type = "nlme" these are passed to nlme::nlmeControl, not nlme::nlme. Additional arguments are documented in fitGrowthbrms, fitGrowthnlme, fitGrowthnls, fitGrowthnlrq, fitGrowthmgcvgam, fitGrowthsurvreg, fitGrowthflexsurv.

Value

A fit model from the selected type.

See also

growthPlot for model visualization, testGrowth for hypothesis testing, barg for Bayesian model reporting metrics.

Examples


simdf <- growthSim("logistic",
  n = 20, t = 25,
  params = list("A" = c(200, 160), "B" = c(13, 11), "C" = c(3, 3.5))
)
ss <- growthSS(
  model = "logistic", form = y ~ time | group,
  df = simdf, type = "nls"
)
fitGrowth(ss)
#> Nonlinear regression model
#>   model: y ~ A[group]/(1 + exp((B[group] - time)/C[group]))
#>    data: ss[["df"]]
#>      A1      A2      B1      B2      C1      C2 
#> 208.049 146.435  13.295  10.952   2.998   3.480 
#>  residual sum-of-squares: 172865
#> 
#> Number of iterations to convergence: 4 
#> Achieved convergence tolerance: 4.541e-08
ss <- growthSS(
  model = "gam", form = y ~ time | group,
  df = simdf, type = "nls"
)
fitGrowth(ss)
#> 
#> Call:
#> stats::lm(formula = ss[["formula"]], data = ss[["df"]])
#> 
#> Coefficients:
#>      (Intercept)         bs(time)1         bs(time)2         bs(time)3  
#>            9.615           -53.526           231.130           190.053  
#>           groupb  bs(time)1:groupb  bs(time)2:groupb  bs(time)3:groupb  
#>           -2.670            66.393           -63.155           -58.386  
#>