IntroAnalysis:::ma223_setup()
library(learnr)

knitr::opts_chunk$set(echo = FALSE)
learnr::tutorial_options(exercise.cap = "Exercise")

```{css, echo=FALSE} / Solution Functionality / .accordion > input[type="checkbox"] { position: absolute; left: -100vw; }

.accordion .content { overflow-y: hidden; height: 0; transition: height 0.3s ease; }

.accordion > input[type="checkbox"]:checked ~ .content { height: auto; overflow: visible; }

.accordion label { display: block; }

/ Styling /

.accordion { margin-bottom: 1em; }

.accordion > input[type="checkbox"]:checked ~ .content { padding: 15px; border: 1px solid #e8e8e8; border-top: 0; }

.accordion .handle { margin: 0; }

.accordion label { cursor: pointer; font-weight: normal; padding: 15px; }

.accordion label:hover, .accordion label:focus { background: #d8d8d8; }

/ Turning arrow / .accordion .handle label:before { font-family: 'fontawesome'; content: "\f054"; display: inline-block; margin-right: 10px; font-size: .58em; line-height: 1.556em; vertical-align: middle; }

.accordion > input[type="checkbox"]:checked ~ .handle label:before { content: "\f078"; }

.tipbox { padding: 1em 1em 1em 1em; border: 1px solid black; border-radius: 10px; box-shadow: 2px 2px #888888; }

.keyidea { border: 1px solid #54585A; background: #4F758B; color: white; }

.keyidea:before { content: "Key Idea: "; font-weight: bold; }

.tip { background: lightyellow; }

.tip:before { content: "Tip: "; font-weight: bold; }

.title{ color: #800000; background: none; }

.solution { background: #ebebeb; }

h2{ color: white; background-color: #800000; }

h3{ color: #800000; border-bottom: thick solid #696969; }

h4{ color: #800000; }

blockquote { font-size: inherit; padding: 0px 20px; }

## Background
According to the 2021 National Survey on Drug Use and Health (NSDUH), 49.3% of full-time college students ages 18 to 22 drank alcohol in the past month. Of those, about 27.4% engaged in binge drinking during that same time frame.  The desire to drink alcohol (a "craving") precedes consumption.  "Alcoholics Anonymous has long claimed that individuals can allay alcohol cravings by eating sweets" [(Cummings 2020)](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7309582/).  This belief suggests that eating sweet foods could be an effective method for managing alcohol cravings and therefore reducing the likelihood that an individual consumes alcohol.

> Around 13% of full-time college students ages 18 to 22 meet the criteria for past-year alcohol use disorder (AUD), according to the 2021 NSDUH.  Alcohol abuse can lead to missed class or schoolwork, depression, attempted suicide, health problems, injuries, and unsafe sexual behavior among other consequences.  If you, or someone you know, is wrestling with alcohol abuse, reach out to a member of the [Rose Cares](https://rosehulman.sharepoint.com/sites/Rosecares/SitePages/Home.aspx) team; or, you can dial the Substance Abuse and Mental Health Services Administration's [national helpline](https://www.samhsa.gov/find-help/national-helpline).

[Cummings, Ray, Nooteboom, and Tomiyama (2020)](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7309582/) conducted a study to investigate the ability of sweet foods to diminish alcohol cravings among "at-risk" drinkers (those who score at least an 8 on the Alcohol Use Disorder Identification Test).  Each participant received a series of cues from a researcher.  The researcher first opened a bottle of water and poured the water into a glass (neutral cue); participants were asked to spend several minutes smelling the beverage.  Following this cue, participants were asked to respond to the question "How much do you crave alcohol right now?" on a visual sliding scale ranging from 0 ("not at all") to 100 ("extremely").

The researcher then opened a bottle of the participant's preferred alcoholic beverage, poured it into a glass, and instructed the participant to smell the beverage (alcohol cue).  Following the cue, the participants indicated their alcohol craving using the visual scale.  Participants were then randomly assigned to receive a type of food to eat.  After 15 minutes, the researcher repeated the alcohol cue and asked participants to indicate their alcohol craving using the visual scale.

For those assigned to consume "bland" foods, participants were given corn tortillas as this was rated "least palatable and rewarding" in a pilot study.  For those assigned to consume "sweet" foods, participants were given a serving of their choice of ice cream, cookies, cupcakes, chocolate, or brownies.

The researchers theorized that if the common belief that sweets can allay alcohol cravings is true, then those participants who receive sweet foods would have a lower alcohol craving at the end of the study compared to those who received bland foods.  We have a subset of this data (`drinking`).  Interest is in determining if the alcohol craving of individuals following the receipt of foods (`Craving_T2`) differs between those who received bland foods and those who received sweet foods (`Condition`).


## Creating the Model
### Exercise: Model for Data Generating Process
> Construct a model for the data generating process comparing the alcohol craving after eating differs between those given sweet foods and those given bland foods.

<section class="accordion tipbox solution">
<input type="checkbox" id="solution1"> 
<h4 class="handle"><label for="solution1">Solution</label></h4>
<div class="content">
In order to construct a model for the data generating process, we must create an indicator variable.  Define

$$(\text{Sweet})_i = \begin{cases} 1 & \text{if i-th participant assigned sweet foods} \\ 0 & \text{if i-th participant assigned bland foods} \end{cases}$$

Now, we can write a model for the data generating process.

$$(\text{Craving})_i = \beta_0 + \beta_1 (\text{Sweet})_i + \varepsilon_i$$

<iframe src="https://rose-hulman.hosted.panopto.com/Panopto/Pages/Embed.aspx?id=3e9a4cd9-7b9b-49ea-b95a-b05f01775391&autoplay=false&offerviewer=true&showtitle=true&showbrand=true&captions=false&interactivity=all" height="405" width="720" style="border: 1px solid #464646;" allowfullscreen allow="autoplay"></iframe>
</div>
</section>


### Exercise: Hypotheses
> Specify the null and alternative hypothesis which captures the question of interest.  Then, specify the model for the data generating process under this null hypothesis.

<section class="accordion tipbox solution">
<input type="checkbox" id="solution2"> 
<h4 class="handle"><label for="solution2">Solution</label></h4>
<div class="content">
$$H_0: \beta_1 = 0 \qquad \text{vs.} \qquad H_1: \beta_1 \neq 0$$

Under the null hypothesis, this results to the following simplified model for the data generating process:

$$(\text{Craving})_i = \beta_0 + \varepsilon_i$$

<iframe src="https://rose-hulman.hosted.panopto.com/Panopto/Pages/Embed.aspx?id=0912400f-a4e7-4d49-aa3d-b05f01775392&autoplay=false&offerviewer=true&showtitle=true&showbrand=true&captions=false&interactivity=all" height="405" width="720" style="border: 1px solid #464646;" allowfullscreen allow="autoplay"></iframe>
</div>
</section>


## Performing Inference
### Exercise: Compute a P-Value
> Suppose we are willing to assume the data is consistent with the conditions for the classical regression model.  Compute an appropriate p-value for testing the above hypotheses.  What conclusions can you draw?

```r
drinking.model.h1 = specify_mean_model()
drinking.model.h0 = specify_mean_model()

compare_models()
drinking.model.h1 = specify_mean_model(Craving_T2 ~ 1 + Condition, 
                                       data = drinking)
drinking.model.h0 = specify_mean_model(Craving_T2 ~ 1, data = drinking)

compare_models(drinking.model.h1, drinking.model.h0,
               alternative = 'not equal',
               assume.constant.variance = TRUE,
               assume.normality = TRUE)

Given the large p-value, the study provides no evidence that individuals who consume bland foods experience a different level of alcohol craving, on average, than those who consume sweet foods. As we think about partitioning variability in this unit, we note that this implies that incorporating the food exposure group does not explain a significant amount of the variability in the alcohol craving of participants. That is what results in a smaller standardized statistic and a larger p-value.

Exercise: Compute a Confidence Interval

Suppose we are willing to assume the data is consistent with the conditions for the classical regression model. Construct a 95% confidence interval for each of the parameters in the model. What do you notice about the confidence interval for the slope?

drinking.model.h1 = specify_mean_model(Craving_T2 ~ 1 + Condition, 
                                       data = drinking)
drinking.model.h0 = specify_mean_model(Craving_T2 ~ 1, data = drinking)
estimate_parameters()
estimate_parameters(drinking.model.h1, 
                    confidence.level = 0.95,
                    assume.constant.variance = TRUE,
                    assume.normality = TRUE)

Notice that the CI includes 0. We are careful not to conclude that the two groups experience the same cravings, on average. More, we should note that the study exposed participants to alcohol after consuming foods; some might interpret the AA belief to mean the use of sweets only following a craving (not prior to one). This is not something we can study with the provided data.


reyesem/IntroAnalysis documentation built on March 29, 2025, 3:29 p.m.