Description Usage Arguments Examples
View source: R/analysis_fit_traj.R
Apply a model fit to an individual's trajectory
1 2 | fit_trajectory(dat, fit, xg = NULL, checkpoints = 365 * c(1:2),
z_bins = -2)
|
dat |
data frame containing variables for one subject to apply a fit to |
fit |
an object returned from |
xg |
grid of x points at which the fit should be evaluated for plotting (if |
checkpoints |
x values at which to compute "checkpoints" of the subjects's growth trajectory to compare to other subjects |
z_bins |
a vector indicating binning of z-scores for the subject's trajectory at each checkpoint with respect to the the WHO growth standard |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | mod <- get_fit(cpp, y_var = "wtkg")
fit <- fit_trajectory(subset(cpp, subjid == 2), mod)
plot(fit$xy$x, fit$xy$y)
lines(fit$fitgrid$x, fit$fitgrid$y)
# there is also a plot method:
plot(fit, x_range = c(0, 2560))
# we can fit the z-scores instead
mod2 <- get_fit(cpp, y_var = "waz")
fit2 <- fit_trajectory(subset(cpp, subjid == 2), mod2)
plot(fit2$xy$x, fit2$xy$z)
lines(fit2$fitgrid$x, fit2$fitgrid$z)
# using the plot method
plot(fit2, x_range = c(0, 2560), center = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.