Lab#

Learning Objectives#

At the end of this learning activity you will be able to:

  • Practice using robust correlation tools that account for outliers.

  • Practice using pg.qqplot and pg.normality to asses the normality of residuals.

  • Practice using regression to create covariate-controlled scores.

import numpy as np
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt

import pingouin as pg

%matplotlib inline
data = pd.read_csv('hiv_neuro_data.csv')
data['education'] = data['education'].astype(float)
data.head()

This lab is going to explore the inter-relationships between two cognitive domains.

  • Executive Function: The complex cognitive processes required for planning, organizing, problem-solving, abstract thinking, and executing strategies. This domain also encompasses decision-making and cognitive flexibility, which is the ability to switch between thinking about two different concepts or to think about multiple concepts simultaneously.

  • Speed of Information Processing: How quickly an individual can understand and react to the information being presented. This domain evaluates the speed at which cognitive tasks can be performed, often under time constraints.

Q1: Are Processing domain and Executive domain scores correlated?#

Checked variables:

  • q1_plot - A regression plot between processing_domain_z and exec_domain_z.

  • q1_corr_res - The result of running pg.corr on processing_domain_z and exec_domain_z.

  • q1_is_corr - A yes/no assessment of the correlation between processing_domain_z and exec_domain_z.

Hint Use the sns.regplot described throughout the Module 9 walkthrough.

Points

5

Public Checks

3

Hidden Tests

1

Points: 5

# Generate a plot between processing_domain_z and exec_domain_z

q1_plot = ...
# Use pg.corr to calculate the correlation between the two variables using a `robust` correlation metric

q1_corr_res = ...
# Are the two domains significantly correlated? 'yes' or 'no'

q1_is_corr = ...
grader.check("q1_domain_corr")

Q2: Create a regression for the processing domain that accounts for the following demographic covariates.#

  • Age

  • Race

  • Sex

  • Education

  • Years Seropositive

  • ART

Checked variables:

  • q2_model_resid_normal - A yes/no assessment of the normality of the residuals after building the model. It should be supported by qqplots and normality tests.

  • q2_processing_age - A yes/no assessment on whether age has a significant impact on processing_domain_z.

  • q2_processing_race - A yes/no assessment on whether race has a significant impact on processing_domain_z.

  • q2_processing_sex - A yes/no assessment on whether sex has a significant impact on processing_domain_z.

  • q2_processing_edu - A yes/no assessment on whether education has a significant impact on processing_domain_z.

  • q2_processing_ys - A yes/no assessment on whether infection length has a significant impact on processing_domain_z.

  • q2_processing_art - A yes/no assessment on whether ART has a significant impact on processing_domain_z.

Hint Recreate the final merged X and y (using processing_domain_z this time) that we created in the Module 9 Walkthrough under the Regression with categories section. Then perform the same regression and interpretion of the results.

Points

10

Public Checks

7

Hidden Tests

7

Points: 10

# Perform the regression using `pg.linear_regression`
# Use the result to answer the questions below
# Assess the normality of the residuals of the model


q2_model_resid_normal = ...
# Considering a p<0.01 threshold answer which of the following are significant

# Age
q2_processing_age = ...

# Race
q2_processing_race = ...

# Sex
q2_processing_sex = ...

# Education
q2_processing_edu = ...

# Infection length
q2_processing_ys = ...

# ART
q2_processing_art = ...
grader.check("q2_exec_adj")

Q3: Comparison#

In the Walkthrough we explored the variables that had an impact on Executive Domain function. This complex cognitive processes required for planning, organizing, problem-solving, abstract thinking, and executing strategies. This domain also encompasses decision-making and cognitive flexibility, which is the ability to switch between thinking about two different concepts or to think about multiple concepts simultaneously.

In this lab you performed a similar analysis to find the variables that impact Processing Domain function. This metric measures how quickly an individual can understand and react to the information being presented. This domain evaluates the speed at which cognitive tasks can be performed, often under time constraints.

In a paragraph compare and contrast the statistically significant variables between the two metrics.

Points: 10

Write your solution here in this box.


grader.check_all()

Submission#

Check:

  • That all tables and graphs are rendered properly.

  • Code completes without errors by using Restart & Run All.

  • All checks pass.

Then save the notebook and the File -> Download -> Download .ipynb. Upload this file to BBLearn.