gam_growthrate: gam_growthrate

View source: R/growthrate_gam.R

gam_growthrateR Documentation

gam_growthrate

Description

posterior simulation for confidence intervals of local slope/growth rate (deriv) of mgcv gam modeled variable (age) - random effects: intercepts only (not predicted)

Usage

gam_growthrate(
  m,
  agevar,
  idvar = NULL,
  n.iterations = 10000,
  qnt = c(0.025, 0.975)
)

Arguments

m

mgcv gam model object (only)

agevar

variable for growth rate

idvar

random effects/subject id variable, set to NULL if none

nnumber

of iterations to run (quick)

qntquantiles

to use for confidence interval

Details

https://people.maths.bris.ac.uk/~sw15190/mgcv/tampere/mgcv-advanced.pdf https://stats.stackexchange.com/questions/190348/can-i-use-bootstrapping-to-estimate-the-uncertainty-in-a-maximum-value-of-a-gam

Examples

 d <- read.csv("/Volumes/Phillips/R03_BehavioralBTC/data/btc_R03scoredmeasures_20190313.csv") %>%
   group_by(id) %>%
   mutate(visit=rank(d8))
 f <- f1score ~ s(Ageatvisit) + s(visit) + s(id, bs="re")
 m <- mgcv::gam(f, data=d)
 ci <- gam_growthrate(m, 'Ageatvisit', 'id')

LabNeuroCogDevel/LNCDR documentation built on July 13, 2024, 10:02 a.m.