-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from alexanderthclark/assignments
cps
- Loading branch information
Showing
41 changed files
with
7,089 additions
and
5,534 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,283 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "073a8bc7", | ||
"metadata": {}, | ||
"source": [ | ||
"# Homework 5" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 20, | ||
"id": "5c4e95f2", | ||
"metadata": { | ||
"tags": [ | ||
"remove-input" | ||
] | ||
}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/html": [ | ||
"\n", | ||
"<!DOCTYPE html>\n", | ||
"<html lang=\"en\">\n", | ||
"<head>\n", | ||
"<meta charset=\"UTF-8\">\n", | ||
"<title>Copy Different Text Example</title>\n", | ||
"<script>\n", | ||
"document.addEventListener('copy', function(e) {\n", | ||
" // Prevent the default copy behavior\n", | ||
" e.preventDefault();\n", | ||
" \n", | ||
" // Get the selected text\n", | ||
" var selectedText = window.getSelection().toString();\n", | ||
" \n", | ||
" // Replace 'above' with 'below'\n", | ||
" var modifiedText = selectedText.replace(/above/gi, \"below\");\n", | ||
" var modifiedText2 = modifiedText.replace(/heteroscedasticity/gi, \"homoscedasticity\");\n", | ||
" \n", | ||
" e.clipboardData.setData('text/plain', modifiedText);\n", | ||
" \n", | ||
"});\n", | ||
"</script>\n", | ||
"</head>\n", | ||
"<body>\n", | ||
"\n", | ||
"<p>\n", | ||
"\n", | ||
"\n", | ||
"You will receive a small data set built from the Current Population Survey. \n", | ||
"Each row describes a married couple. Review the data documentation for more information on each of the columns.\n", | ||
"\n", | ||
"<table border=\"1\" class=\"dataframe\">\n", | ||
" <thead>\n", | ||
" <tr style=\"text-align: right;\">\n", | ||
"\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>Documentation Variable Name</th>\n", | ||
" <th>Sheets Column Name</th>\n", | ||
" </tr>\n", | ||
" </thead>\n", | ||
" <tbody>\n", | ||
" <tr>\n", | ||
" <th>TUCASEID</th>\n", | ||
" <td>TUCASEID (identifier for the couple)</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>PRERNWA</th>\n", | ||
" <td>partner* earnings</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>PEEDUCA</th>\n", | ||
" <td>partner* educ</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>PRTAGE</th>\n", | ||
" <td>partner* age</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>PESEX</th>\n", | ||
" <td>partner* sex</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>PTDTRACE</th>\n", | ||
" <td>partner* race</td>\n", | ||
" </tr>\n", | ||
" </tbody>\n", | ||
"</table>\n", | ||
"\n", | ||
"<br> <br>\n", | ||
"Submit your work in two files: (1) a main document, pdf or doc file, that answers each question and provides the statistical reasoning but not the actual calculations\n", | ||
"and (2) a supplementary file for calculations, either xlsx or a code file.\n", | ||
"This is your proof-of-work, replication file.\n", | ||
"\n", | ||
"<br>\n", | ||
"\n", | ||
"<br>\n", | ||
"\n", | ||
"1. Create a scatter diagram that relates a partner 1 column and partner 2 column. Use quantitative variables only.\n", | ||
"Use these two columns for the following questions. <br>\n", | ||
"2. Find the regression line equation. Let the partner 1 column be the independent variable. <br>\n", | ||
"3. Interpret the regression line in the context of the data: what do the coefficients mean? <br>\n", | ||
"4. Discuss if linear regression is appropriate for the data. <br>\n", | ||
"5. Find the root mean square error. Interpret this, assuming the residuals follow a normal curve. <br>\n", | ||
"6. Create a residual plot. Do you detect any non-linear pattern or heteroscedasticity? <br>\n", | ||
"7. What is the empirical probability that a partner 1 value is above average? \n", | ||
"Conditional on a positive residual, what is the empirical probability that the partner 1 value is above average?\n", | ||
"Does this support your answer to the previous question? <br>\n", | ||
"8. The labeling of parter 1 and partner 2 within each row is somewhat arbitrary. \n", | ||
"Reorganize the data in a way that (1) doesn't split any of the couples and (2) doesn't simply relabel every partner 1 as partner 2 and vice versa.\n", | ||
"Some (x,y) pairs will stay the same and others will be flipped. \n", | ||
"Describe how you did this and find a new regression line. Comment on how the interpretation of the regression line changes, if it does. \n", | ||
"\n", | ||
"\n", | ||
"\n", | ||
"</p>\n", | ||
"\n", | ||
"</body>\n", | ||
"</html>\n", | ||
"\n" | ||
], | ||
"text/plain": [ | ||
"<IPython.core.display.HTML object>" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"from IPython.display import display, HTML\n", | ||
"\n", | ||
"assignment = '''\n", | ||
"\n", | ||
"You will receive a small data set built from the Current Population Survey. \n", | ||
"Each row describes a married couple. Review the data documentation for more information on each of the columns.\n", | ||
"\n", | ||
"<table border=\"1\" class=\"dataframe\">\n", | ||
" <thead>\n", | ||
" <tr style=\"text-align: right;\">\n", | ||
"\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>Documentation Variable Name</th>\n", | ||
" <th>Sheets Column Name</th>\n", | ||
" </tr>\n", | ||
" </thead>\n", | ||
" <tbody>\n", | ||
" <tr>\n", | ||
" <th>TUCASEID</th>\n", | ||
" <td>TUCASEID (identifier for the couple)</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>PRERNWA</th>\n", | ||
" <td>partner* earnings</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>PEEDUCA</th>\n", | ||
" <td>partner* educ</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>PRTAGE</th>\n", | ||
" <td>partner* age</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>PESEX</th>\n", | ||
" <td>partner* sex</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>PTDTRACE</th>\n", | ||
" <td>partner* race</td>\n", | ||
" </tr>\n", | ||
" </tbody>\n", | ||
"</table>\n", | ||
"\n", | ||
"<br> <br>\n", | ||
"Submit your work in two files: (1) a main document, pdf or doc file, that answers each question and provides the statistical reasoning but not the actual calculations\n", | ||
"and (2) a supplementary file for calculations, either xlsx or a code file.\n", | ||
"This is your proof-of-work, replication file.\n", | ||
"\n", | ||
"<br>\n", | ||
"\n", | ||
"<br>\n", | ||
"\n", | ||
"1. Create a scatter diagram that relates a partner 1 column and partner 2 column. Use quantitative variables only.\n", | ||
"Use these two columns for the following questions. <br>\n", | ||
"2. Find the regression line equation. Let the partner 1 column be the independent variable. <br>\n", | ||
"3. Interpret the regression line in the context of the data: what do the coefficients mean? <br>\n", | ||
"4. Discuss if linear regression is appropriate for the data. <br>\n", | ||
"5. Find the root mean square error. Interpret this, assuming the residuals follow a normal curve. <br>\n", | ||
"6. Create a residual plot. Do you detect any non-linear pattern or heteroscedasticity? <br>\n", | ||
"7. What is the empirical probability that a partner 1 value is above average? \n", | ||
"Conditional on a positive residual, what is the empirical probability that the partner 1 value is above average?\n", | ||
"Does this support your answer to the previous question? <br>\n", | ||
"8. The labeling of parter 1 and partner 2 within each row is somewhat arbitrary. \n", | ||
"Reorganize the data in a way that (1) doesn't split any of the couples and (2) doesn't simply relabel every partner 1 as partner 2 and vice versa.\n", | ||
"Some (x,y) pairs will stay the same and others will be flipped. \n", | ||
"Describe how you did this and find a new regression line. Comment on how the interpretation of the regression line changes, if it does. \n", | ||
"\n", | ||
"'''\n", | ||
"\n", | ||
"\n", | ||
"s = '''\n", | ||
"<!DOCTYPE html>\n", | ||
"<html lang=\"en\">\n", | ||
"<head>\n", | ||
"<meta charset=\"UTF-8\">\n", | ||
"<title>Copy Different Text Example</title>\n", | ||
"<script>\n", | ||
"document.addEventListener('copy', function(e) {\n", | ||
" // Prevent the default copy behavior\n", | ||
" e.preventDefault();\n", | ||
" \n", | ||
" // Get the selected text\n", | ||
" var selectedText = window.getSelection().toString();\n", | ||
" \n", | ||
" // Replace 'above' with 'below'\n", | ||
" var modifiedText = selectedText.replace(/above/gi, \"below\");\n", | ||
" var modifiedText2 = modifiedText.replace(/heteroscedasticity/gi, \"homoscedasticity\");\n", | ||
" \n", | ||
" e.clipboardData.setData('text/plain', modifiedText);\n", | ||
" \n", | ||
"});\n", | ||
"</script>\n", | ||
"</head>\n", | ||
"<body>\n", | ||
"\n", | ||
"<p>\n", | ||
"''' + assignment + '''\n", | ||
"\n", | ||
"</p>\n", | ||
"\n", | ||
"</body>\n", | ||
"</html>\n", | ||
"\n", | ||
"'''\n", | ||
"\n", | ||
"display(HTML(s))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "90899992", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "6c8c9386", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"celltoolbar": "Edit Metadata", | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.5" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.