neverConsumers: Identify Never-Consumers in Zero Inflated Poisson Models

Description Usage Arguments Value Examples

View source: R/neverConsumers.R

Description

A function to estimate percentage of never-consumers in the context of nutrition. The method implemented in this function has been developed in the paper "Measurement error models with zero - inflation and multiple sources of zero with an application to the never consumers problem in nutrition". If we have data on whether or not a person has consumed a certain food on the day of the study, amount of food consumed and energy obtained with a bunch of covariates and multiple recalls then we can use this function to model the data and obtain an estimate of the percentage of never-consumers of the food of interest. The data for this function must include number of recalls and the response in three different variable (i.e. an indicator of food consumed, amount of food consumed and amount of energy generated from the food). It also needs some covariates. A list of other parameters that must be specified by the user are given below.

Usage

1
2
3
neverConsumers(zz, mmi, X_cols, Food_col, Energy_col, ID_col, FFQ_food_col,
FFQ_energy_col, with_covariates_ind, n_gen, lambda_rec_food, lambda_rec_energy, 
lambda_FFQ_food, lambda_FFQ_energy,beta_temp, Sigmau_temp_episodically)

Arguments

zz

The dataset in the form of a dataframe with headers.

mmi

Number of Recalls, it should be an integer.

X_cols

Column id's specifying where the covariates are

Food_col

Column id specifying where the episodic variable is

Energy_col

Column id specifying where energy (continuous) is

ID_col

Column id for ID of the subjects

FFQ_food_col

Column where the FFQ for the food is. Set = [] if no FFQ. Please be aware that if there is a FFQ, you really should add this in, because FFQ have a tendency to generate massive, high leverage outliers, as in the EATS data

FFQ_energy_col

Column where the FFQ for energy is. Set = [] if no FFQ Please be aware that if there is a FFQ, you really should add this in, because FFQ have a tendency to generate massive, high leverage outliers, as in the EATS data

with_covariates_ind

What to include as covariates in the ever consumer model; 0: a column of ones; 1: a column of ones, the FFQ, and the indicator that the FFQ=0; 2: a column of ones and the FFQ; 3: a column of ones and the indicator that the FFQ=0. By default the value is set to 3.

n_gen

Number of realizations of usual intake to generate. Must be a positive integer, or 0 if no realizations to be generated. Default is 1.

lambda_rec_food

lambda value required for BoxCox transformation on food. Default is 0.5.

lambda_rec_energy

lambda value required for BoxCox transformation on energy. Default is 0.5.

lambda_FFQ_food

lambda value required for BoxCox transformation on FFQ for the food. Default is 0.5.

lambda_FFQ_energy

lambda value required for BoxCox transformation on FFQ for the energy. Default is 0.5.

beta_temp

initial value for beta_temp. By default it is a matrix of zero's.

Sigmau_temp_episodically

initial value for Sigmau_temp. By default a matrix with diagonal elements 1 and off-diagonals 0.5

nburn

Size of the burnin. Default value is 10000.

nMCMC

Number of MCMC iterations. The more the better. Default value is 50000.

nthin

Thining. Default value is 50.

ndist

average of the last ndist MCMC steps (after thinning) to get the cdf of usual intake. Default value is 200.

beta_start_ind

the starting value of beta. By default set to 9999: episodically; all other number: a 5*3 matrix with the number as each cell. This should be an integer.

beta_prior_mean_ind

the prior mean for beta 9999: episodically (estimated by Saijuan's code) 0: regular (a 5*3 matrix with all elements = 0). Please specify either 9999 or 0.

rw_ind

do you want to use the random walk proposal for beta_1? 1: yes, use random walk proposal with Normal(beta_1, C_2 * M); 0: no, use Normal(C_2*C_1, C_2*M). Please specify either 1 or 0. Default value is 1

update_beta1_var_ind

the variance for updating beta1, i.e. this is the M in Normal(beta_1, C_2*M) and Normal(C_2 * C_1, C_2 *M). It has to be a positive number. Default value is 0.5

Sigmau_start_ind

the starting value of Sigmau; 1: episodically (estimated by Saijuan's code); 2: regular (a 3*3 matrix with diagonal elements = 1 and offdiagonal elements = 0.5) .Please specify either 1 or 2. Default value is 1

Sigmau_prior_mean_ind

the prior mean for Sigmau; 1: episodically (estimated by Saijuan's code); 2: regular (a 3*3 matrix with diagonal elements = 1 and off-diagonal elements = 0.5); 3: half of regular. Please specify either 1 or 2. Default value is 2

ndim

the number of dimensions, here by default set to 3 for indicator, amount and energy. Should be an integer.

beta1_accept_count

count how many times beta1 moves. Default value is 0.

myseed

initialize random seed

Value

alpha_postmean,alpha_postsd, alpha_ci Mean, Sd and CI's of the mean parameter of the prior distribution of percentage of never consumers
never_postmean, never_postsd, never_ci Mean, Sd and CI's of the percentage of never consumers
beta_postmean, beta_postsd, beta_ci Mean, Sd and CI's of slope parameters for the covariates
Sigmau_postmean, Sigmau_postsd, Sigmau_ci Mean, Sd and CI's of the variance covariance matrix of the random effects
Sigmae_postmean, Sigmae_postsd, Sigmae_ci Mean, Sd and CI's of the variance covariance matrix of the white noise
mu_ui_food, sig_ui_food Mean and Sd of the distribution of usual intake of food
mu_ui_energy, sig_ui_energy Mean and Sd of the distribution of usual intake of the ratio = food/(energy/1000)
mu_ui_ratio, sig_ui_ratio Mean and Sd of the distribution of usual intake of energy
food_distribution, energy_distribution and ratio_distribution Percentiles of the distribution of usual intake of food, energy and food/(energy/1000)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# load the data
zz <- read.csv(file.choos(), header = T)

# specify all the required parameters with no default values
X_cols          <- 2:5 # Columns where the covariates are
Food_col        <- 6 # Column where the episodic variable is
Energy_col      <- 7 # Column where energy (continuous) is
ID_col          <- 1 # Column for ID
FFQ_food_col    <- 4 # Column where the FFQ for the food is. 
FFQ_energy_col  <- 5 # Column where the FFQ for energy is. 
with_covariates_ind <- 3# What to include as covariates in the
mmi             <- 4# Number of recalls, integer

# make the function call as follows:

neverConsumers(zz, mmi, X_cols, Food_col, Energy_col, ID_col, FFQ_food_col,
FFQ_energy_col, with_covariates_ind)

ananyarc94/NeverConsumers documentation built on Dec. 19, 2021, 2:33 a.m.