Single nutrient density or ratio of two components (the denominator must be regularly-consumed)

Programs and related files for examples on this page

 Download InfographicDownload files
(ZIP, 11.8 MB)




First, call the NLMIXED_UNIVARIATE macro twice (once for the numerator variable, and once for the denominator variable) to get starting estimates for subsequent NLMIXED_BIVARIATE calls.  The BOXCOX_SURVEY macro can be used to choose a Box-Cox transformation parameter for the nonzero amounts of each dietary variable, and the Box-Cox transformation parameter can be used as input to the NLMIXED_UNIVARIATE macro.

Because replication methods (bootstrap or BRR) are used to estimate standard errors of calculated statistics, the following tasks must be performed repeatedly – once for the original data set (or using the base sampling weight variable) to obtain point estimates and again for each resampled data set (or using each of the bootstrap/BRR weight variables in turn):

  1. Use the NLMIXED_BIVARIATE macro to fit the measurement error model and store parameter estimates, then
  2. Use the parameter estimates as input to the DISTRIB_BIVARIATE macro to simulate a representative sample of usual intakes (of both dietary variables) for the population, then compute nutrient density for each record in the simulated data set, then
  3. Use PERCENTILES_SURVEY or similar code to calculate and store desired statistics (e.g., percentiles, cutpoint probabilities) from the density variable in the simulated sample.

After calculating desired statistics for all data sets/sampling weights, use the appropriate bootstrap/BRR algorithms to estimate standard errors (see the BRR_PVALUE_CI macro) by taking the square root of the (adjusted, if BRR) variance across replicates.


  • Standard errors for model parameter estimates are printed as part of the NLMIXED_BIVARIATE output, but are not valid unless data are from a simple random sample. Calculation of standard errors of statistics derived from the model (such as percentiles) require resampling methods, so for consistency, one can also apply bootstrap/BRR algorithms to saved parameter data sets to estimate standard errors for model parameters.
  • The DISTRIB_BIVARIATE macro only generates a data set of simulated true intakes for the numerator and denominator variables, reflecting only the (sub)populations represented in the data set used in the preceding NLMIXED_BIVARIATE run. Therefore, when separate NLMIXED_BIVARIATE/DISTRIB_BIVARIATE runs are required to model an entire population, whole-population percentiles must be computed outside DISTRIB_BIVARIATE after combining multiple simulated samples.
  • Because the simulated data set output by DISTRIB_BIVARIATE retains subject ID, one can merge subject-level variables from the original data into the simulated data set, e.g., in the case where a single categorical subpopulation variable is desired in place of dummy variables used in NLMIXED_BIVARIATE. However, subpopulation estimates are only valid if their defining information was used in the NLMIXED_BIVARIATE run. For example, if dummy variables indicating membership in age categories were used in the NLMIXED_BIVARIATE run, then it is appropriate to compute percentiles by those age categories, after merging in a single variable for those age groups. However, if race/ethnicity information was also merged back in, but no corresponding dummy variables were used in NLMIXED_BIVARIATE, it would not be appropriate to compute percentiles for race/ethnicity subpopulations.
  • Statistics of interest may include differences in percentiles or cutpoint probabilities between subgroups, or conditional distributions of intake density given usual intake of energy falls within a given range. Standard errors for these sorts of statistics can generally be computed using BRR/bootstrap formulas.

Example Code


  • and - fit univariate measurement error models using MLE with 24-hour recall as main instrument to obtain starting values for the subsequent steps.
  • - fit bivariate measurement error models using MLE with 24-hour recall as main instrument.
  • - simulate representative sample of ratios of usual intakes and estimate percentiles and cutpoint probabilities of the population distribution.
  • - perform balanced repeated replication (BRR) variance estimation.