knitr::opts_chunk$set(collapse = TRUE, comment = "#>") library(hbgd)
The growth velocity function allows you to apply a function to the first derivative of growth trajectories. For example, taking the mean of the first derivative. Since the function depends on growth trajectories, they need to be generated first; see documentation for HBGD package.
smc <- get_smocc_data()[1:500,] smc_haz_wandfit <- get_fit(smc, y_var = "haz", method = "wand") smc_tr <- fit_all_trajectories(smc, smc_haz_wandfit)
Suppose we assign the trajectories to a variable named traj
. We call
the growth velocity method as follows:
traj_velocity <- get_traj_velocity(all_traj = smc_tr)
The result of this call will be a
tibble. Each row
of this tibble
has the subject ID and growth velocity.
print(traj_velocity)
all_traj
The returned value from calling fit_all_trajectories
function. This is mandatory.z_score = TRUE
will use the z-scores, e.g., haz
. The default
value is TRUE
.agedays_floor = 0.00
specifies the minimum agedays
to use.
The default value is zero.
This parameter, combined with agedays_limit
, extracts the required
ranges of the fitted trajectory.
Note that times depends heavily on the the number of grid points used to
generate the trajectories, which is specified by the xg
parameter for the
functions hbgd::fit_trajectory
and hbgd::fit_all_trajectories
.
This is because the function supplied by FUN
will be applied to
derivative data with x-axis grid value less than agedays_limit
; the
x-axis grid values are set up by xg
parameter of the
functions hbgd::fit_trajectory
and hbgd::fit_all_trajectories
. agedays_limit = 365
specifies the maximum agedays
to use.
The default value is one year (365 days).
This parameter, combined with agedays_floor
, extracts the required
ranges of the fitted trajectory.
Note that times depends heavily on the the number of grid points used to
generate the trajectories, which is specified by the xg
parameter for the
functions hbgd::fit_trajectory
and hbgd::fit_all_trajectories
.
This is because the function supplied by FUN
will be applied to
derivative data with x-axis grid value less than agedays_limit
; the
x-axis grid values are set up by xg
parameter of the
functions hbgd::fit_trajectory
and hbgd::fit_all_trajectories
.FUN
argument takes a function specified by the user that will
be apply on the growth trajectory data. This function should only
receive one argument, a vector containing the first derivative
of the growth trajectory. Since the first derivative can contain
NA
value (e.g., derivative for the first growth data), the supplied
function should be able to handle NA
values. The default for this
argument is an internal function that simply calculates the mean.Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.