2023-11-12

Background Information of Experiment

In this presentation, the plausibility of a correlation between a decreased level of mental concentration and anorexia by using a Sample T-Test is explored. The null hypothesis will be based on the sample mean of mental concentration for all the patients in this data-set, which will be treated as a population mean. The alternative hypothesis will be based on the sample mean of mental concentration of patients with anorexia being less than the the population mean of all patients in the data-set previously mentioned. (In this data set, some mentally ill patients suffer from anorexia,while others do not). The steps to complete this Hypotheses Test (specifically a T-Test for this case) is as Follows:

  1. Compute u=population mean “mew” (sample mean of all patients in data-set) (this will be our null hypothesis mean value)
  2. Compute u0=sample mean (sample mean of patients with anorexia)
  3. Affirm that our alternative hypothesis will be: u<u0
  4. Affirm that we will use a Type-1 Error of a=0.05 for testing
  5. Compute the test statistic (t0)
  6. Compute the p-value
  7. Accept or reject the null hypothesis based on the computed p-value
  8. Draw conclusions from our T-Test results
All references to “concentration” in this presentation refer to mental concentration levels of the patients in the data set

Formulas used for this Hypothesis T-Test

Mental concentration levels of patients are given on a scale from 0-10, 10 being the most concentrated, while 0 is no concentration at all

  1. Calculate sample mean of concentration levels (the first sample mean based on the full data set will be considered as the population mean, while the sample mean of patients with anorexia will be considered as the sample mean)
    \(\bar{x} = \frac{\sum_{i=1}^{n} x_i}{n}\)
  2. Calculate sample standard deviation of mental concentration levels of patients with anorexia
    \(s={\sqrt {\frac {\sum _{i=1}^{n}(x_{i}-{\overline {x}})^{2}}{N-1}}}\)
  3. Determine arbitrary Type-1 Error we want to use (a=0.05 is pretty standard)
    \(a=0.05\)
  4. Note down the total sample size (amount of patients with anorexia)
    \(n\)
  5. Calculate the T-Test, Test Statistic
    \(t_0 = \frac{\bar{x}-u_0}{s / \sqrt{n}}\)
  6. Calculate P-Value for the less-than alternative hypothesis version of the T-Test
    \(p_{value} = F(t_0)\)
  7. Determine if the null can or cannot be rejected (answer to our Hypothesis T-Test) Is \(p_{value} < a\) ? If this is true, then the null is rejected, if it is NOT true, then the null cannot be rejected (or that we just need a larger value of data samples for which we may find that the null should be rejected)

u<u0 T-Test Conlusion Standards

If the null is rejected, this means that it can be concluded that patients who suffer from mental illness with anorexia seem to experience more mental concentration difficulties than patients suffering with mental illness who do NOT have anorexia.

If we cannot reject the null, it can be concluded that there does not seem to be a correlation between mental concentration difficulties of patients suffering with mental illness who have anorexia vs patients suffering from mental illness who do not have anorexia (or the data set used is too small)



\(p_{value} < a = true\)

means the we reject the null


\(p_{value} < a = false\)

means the we failt to reject the null

R-Code Implementing T-Test

# compute sample mean of mental concentration levels of all
# patients
pop_concent_mean <- mean(concentration)

# compute sample mean of mental concentration levels of
# patients with anorexia
anorex <- mental_disorders %>%
    filter(grepl("yes", anorxia))

anorex_concent_mean <- mean(anorex$concentration)

# compute sample standard deviation of sample of patients
# with anorexia
anorex_concent_sd <- sd(anorex$concentration)

R-Code Implementing T-Test (continued)

alpha <- 0.05  # Arbitrary Type-1 Error Value for this Test

anorex_amount <- nrow(anorex)  # Number of patients with anorexia

# Compute test statistic
t0 <- (anorex_concent_mean - pop_concent_mean)/(anorex_concent_sd/sqrt(anorex_amount))

# compute p-value [dt(x, df) = t-distribution] for u<u0
# alternative hypothesis
anorex_pvalue <- dt(t0, (anorex_amount - 1))

# determine if T-Test for H0: u=u0, H1: u<u0 rejects the
# null
ttest_result <- anorex_pvalue < alpha
ttest_result  # true = reject the null, false = cannot reject the null
## [1] FALSE
knitr::opts_chunk$set(warning = FALSE)

Plotly: Visualize data sample in Histogram

This histogram graph visualizes the full data set to allow the analyzer to obtain a general idea of the size and quality of the data set being analyzed.

ggplot 1: Boxplot

Though the previous T-Test found anorexia to be statistically insignificant with regards to mental concentration levels in patients suffering from mental illness, it can observed that the lower quartile of patients with mental illness and anorexia experience an average lower concentration levels compared to the lower quartile of patients with mental illness and no anorexia.

ggplot 2: Frequency Plot (No Anorexia)

The following frequency plot displays the frequency of mental concentration levels for patients suffering from mental illness without anorexia from the data set:

ggplot 3: Frequency Plot (With Anorexia)

The following frequency plot displays the frequency of mental concentration levels for patients suffering from mental illness with anorexia from the data set:

Hypothesis Test and Visual Data Analysis Conclusion

After this hypothesis test and data analysis through different chart/graph types, there are three main conclusions:

  1. The T-Test concludes that for this data set, there is insignificant evidence to support the idea that for patients suffering from a mental illness, that additionally suffering from anorexia worsens mental concentration levels.
  2. Different chart/graph types however do allow for the observation that lower concentration levels in patients with mental illness do appear more prevalent in such patients who additionally suffer from anorexia
  3. Even with these graphical observations, it cannot be assumed that patients who suffer from both mental illness and anorexia have a lower mental concentration level than patients who suffer from mental illness but not anorexia. If for whatever reason there is a hypothesis that anorexia in mentally ill patients negatively impacts mental concentration levels, and that the hypothesis test performed here is incorrect, then a larger random data sample of patients suffering from mental illness and patients suffering from mental illness and anorexia should be collected to re-run a hypothesis test with a larger data set.
Source of Data: https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/0FNET5