Creates the model specifications for xname

make_xname(yname, xnames, user_model, current_age)

Arguments

yname

String indicating the dependent variable

xnames

Character vector of available names to choose from. It is assumed all variables named in xnames have complete data. Any brokenstick variable should have names like paste(yname, d, sep = "_"), where d is a vector contuining decimal ages.

user_model

Model number (1-4), indicating type of model the user wants. See details.

current_age

Current age (in decimal years)

Value

A character vector with the xname specification

Examples

xnames <- c(
  "sex", "ga", "bw", "hgt_0", "hgt_1", "hgt_3",
  "wgt_0", "wgt_1", "wgt_2", "junk"
)

# note that it does not return hgt2
chartplotter:::make_xname(
  yname = "hgt", xnames = xnames, user_model = 2,
  current_age = 2
)
#> [1] "sex"