|
@@ -174,7 +174,7 @@
|
|
|
"type": "string"
|
|
"type": "string"
|
|
|
}
|
|
}
|
|
|
],
|
|
],
|
|
|
- "ref": "fa6f2da9-e7ce-4d2b-a902-6ed191c7e0b1",
|
|
|
|
|
|
|
+ "ref": "66ec0b2c-7162-496b-8dc0-9b27c483f7fb",
|
|
|
"rows": [
|
|
"rows": [
|
|
|
[
|
|
[
|
|
|
"0",
|
|
"0",
|
|
@@ -389,7 +389,7 @@
|
|
|
"type": "integer"
|
|
"type": "integer"
|
|
|
}
|
|
}
|
|
|
],
|
|
],
|
|
|
- "ref": "65f5bd4f-e917-4132-af97-1aa54ad404c6",
|
|
|
|
|
|
|
+ "ref": "1218ecb3-a871-4f81-8dce-d02e4a6d11ab",
|
|
|
"rows": [
|
|
"rows": [
|
|
|
[
|
|
[
|
|
|
"0",
|
|
"0",
|
|
@@ -560,7 +560,7 @@
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
"cell_type": "code",
|
|
"cell_type": "code",
|
|
|
- "execution_count": null,
|
|
|
|
|
|
|
+ "execution_count": 6,
|
|
|
"id": "0adcb6fe",
|
|
"id": "0adcb6fe",
|
|
|
"metadata": {},
|
|
"metadata": {},
|
|
|
"outputs": [],
|
|
"outputs": [],
|
|
@@ -601,7 +601,7 @@
|
|
|
"type": "integer"
|
|
"type": "integer"
|
|
|
}
|
|
}
|
|
|
],
|
|
],
|
|
|
- "ref": "6a990d52-0086-4c59-8aa5-d7acc2d83825",
|
|
|
|
|
|
|
+ "ref": "ca8fd6c7-b9dd-4788-ac6f-2e13a8e6fefd",
|
|
|
"rows": [
|
|
"rows": [
|
|
|
[
|
|
[
|
|
|
"0",
|
|
"0",
|
|
@@ -693,7 +693,7 @@
|
|
|
"type": "float"
|
|
"type": "float"
|
|
|
}
|
|
}
|
|
|
],
|
|
],
|
|
|
- "ref": "431bd473-d76e-451e-ab03-9ca002c3a0c4",
|
|
|
|
|
|
|
+ "ref": "a155abc4-822b-4f7e-a9c5-db2b6366a90e",
|
|
|
"rows": [
|
|
"rows": [
|
|
|
[
|
|
[
|
|
|
"0",
|
|
"0",
|
|
@@ -790,6 +790,9 @@
|
|
|
"\n",
|
|
"\n",
|
|
|
"plt.xlabel('T')\n",
|
|
"plt.xlabel('T')\n",
|
|
|
"plt.ylabel('Z')\n",
|
|
"plt.ylabel('Z')\n",
|
|
|
|
|
+ "\n",
|
|
|
|
|
+ "plt.savefig(\"results/contingency_table.png\", dpi=300, bbox_inches='tight')\n",
|
|
|
|
|
+ "\n",
|
|
|
"plt.show()"
|
|
"plt.show()"
|
|
|
]
|
|
]
|
|
|
},
|
|
},
|
|
@@ -847,7 +850,7 @@
|
|
|
"type": "float"
|
|
"type": "float"
|
|
|
}
|
|
}
|
|
|
],
|
|
],
|
|
|
- "ref": "b07a4aad-7af4-4c42-9300-d0d0733cf936",
|
|
|
|
|
|
|
+ "ref": "fba2a65e-834d-485a-a68c-7f0982111e5b",
|
|
|
"rows": [
|
|
"rows": [
|
|
|
[
|
|
[
|
|
|
"0",
|
|
"0",
|
|
@@ -952,7 +955,7 @@
|
|
|
"type": "float"
|
|
"type": "float"
|
|
|
}
|
|
}
|
|
|
],
|
|
],
|
|
|
- "ref": "80760edf-29c5-49fb-90a7-e16f1026f646",
|
|
|
|
|
|
|
+ "ref": "89af0b1d-1663-4d0d-a4da-dc4fcd752e41",
|
|
|
"rows": [
|
|
"rows": [
|
|
|
[
|
|
[
|
|
|
"0",
|
|
"0",
|
|
@@ -1044,7 +1047,7 @@
|
|
|
"type": "float"
|
|
"type": "float"
|
|
|
}
|
|
}
|
|
|
],
|
|
],
|
|
|
- "ref": "eb14d2c3-8c28-47e2-b4b8-979e7b202dde",
|
|
|
|
|
|
|
+ "ref": "ba2f7e51-78dd-4a7f-b472-8d9205308ef4",
|
|
|
"rows": [
|
|
"rows": [
|
|
|
[
|
|
[
|
|
|
"0",
|
|
"0",
|
|
@@ -1322,7 +1325,7 @@
|
|
|
"type": "boolean"
|
|
"type": "boolean"
|
|
|
}
|
|
}
|
|
|
],
|
|
],
|
|
|
- "ref": "e26dba4c-dc0c-4b6f-855a-e61accb0f5a1",
|
|
|
|
|
|
|
+ "ref": "52915e30-0084-4139-9619-614639d91171",
|
|
|
"rows": [
|
|
"rows": [
|
|
|
[
|
|
[
|
|
|
"0",
|
|
"0",
|
|
@@ -1474,7 +1477,7 @@
|
|
|
}
|
|
}
|
|
|
],
|
|
],
|
|
|
"source": [
|
|
"source": [
|
|
|
- "df_prentice = utils.prentice_criteria(\n",
|
|
|
|
|
|
|
+ "df_prentice1 = utils.prentice_criteria(\n",
|
|
|
" df_work,\n",
|
|
" df_work,\n",
|
|
|
" endpoint=\"T\",\n",
|
|
" endpoint=\"T\",\n",
|
|
|
" surrogate=\"S\",\n",
|
|
" surrogate=\"S\",\n",
|
|
@@ -1485,7 +1488,219 @@
|
|
|
" criterion2_test=\"ks\",\n",
|
|
" criterion2_test=\"ks\",\n",
|
|
|
")\n",
|
|
")\n",
|
|
|
"\n",
|
|
"\n",
|
|
|
- "df_prentice"
|
|
|
|
|
|
|
+ "df_prentice1"
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "cell_type": "code",
|
|
|
|
|
+ "execution_count": 14,
|
|
|
|
|
+ "id": "463b5b1c",
|
|
|
|
|
+ "metadata": {},
|
|
|
|
|
+ "outputs": [
|
|
|
|
|
+ {
|
|
|
|
|
+ "data": {
|
|
|
|
|
+ "application/vnd.microsoft.datawrangler.viewer.v0+json": {
|
|
|
|
|
+ "columns": [
|
|
|
|
|
+ {
|
|
|
|
|
+ "name": "index",
|
|
|
|
|
+ "rawType": "int64",
|
|
|
|
|
+ "type": "integer"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "name": "Criterion",
|
|
|
|
|
+ "rawType": "object",
|
|
|
|
|
+ "type": "string"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "name": "Method",
|
|
|
|
|
+ "rawType": "object",
|
|
|
|
|
+ "type": "string"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "name": "Model",
|
|
|
|
|
+ "rawType": "object",
|
|
|
|
|
+ "type": "string"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "name": "Estimate",
|
|
|
|
|
+ "rawType": "float64",
|
|
|
|
|
+ "type": "float"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "name": "P-value",
|
|
|
|
|
+ "rawType": "object",
|
|
|
|
|
+ "type": "unknown"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "name": "Pass",
|
|
|
|
|
+ "rawType": "boolean",
|
|
|
|
|
+ "type": "boolean"
|
|
|
|
|
+ }
|
|
|
|
|
+ ],
|
|
|
|
|
+ "ref": "1998c6dd-7ade-4525-b555-7017507076e6",
|
|
|
|
|
+ "rows": [
|
|
|
|
|
+ [
|
|
|
|
|
+ "0",
|
|
|
|
|
+ "1. Treatment -> True",
|
|
|
|
|
+ "Fisher's exact test",
|
|
|
|
|
+ "Z x T (2x2 table)",
|
|
|
|
|
+ "0.6720937713621131",
|
|
|
|
|
+ "0.4873416561256851",
|
|
|
|
|
+ "False"
|
|
|
|
|
+ ],
|
|
|
|
|
+ [
|
|
|
|
|
+ "1",
|
|
|
|
|
+ "2. Treatment -> Surrogate",
|
|
|
|
|
+ "Kolmogorov–Smirnov test",
|
|
|
|
|
+ "S by Z groups",
|
|
|
|
|
+ "0.28851540616246496",
|
|
|
|
|
+ "0.5879664894834571",
|
|
|
|
|
+ "False"
|
|
|
|
|
+ ],
|
|
|
|
|
+ [
|
|
|
|
|
+ "2",
|
|
|
|
|
+ "3. Surrogate -> True",
|
|
|
|
|
+ "Logistic",
|
|
|
|
|
+ "T ~ S",
|
|
|
|
|
+ "10.73815933915853",
|
|
|
|
|
+ "0.004114055500597262",
|
|
|
|
|
+ "True"
|
|
|
|
|
+ ],
|
|
|
|
|
+ [
|
|
|
|
|
+ "3",
|
|
|
|
|
+ "4. Full Mediation",
|
|
|
|
|
+ "Logistic",
|
|
|
|
|
+ "T ~ S + Z",
|
|
|
|
|
+ "1.0343270483046114",
|
|
|
|
|
+ "0.6441919482170702",
|
|
|
|
|
+ "True"
|
|
|
|
|
+ ],
|
|
|
|
|
+ [
|
|
|
|
|
+ "4",
|
|
|
|
|
+ "Proportion Explained (PE)",
|
|
|
|
|
+ "Logistic coefficients",
|
|
|
|
|
+ "Compare Z in (T ~ Z) vs (T ~ S + Z).",
|
|
|
|
|
+ "-0.5389624072967832",
|
|
|
|
|
+ null,
|
|
|
|
|
+ "False"
|
|
|
|
|
+ ]
|
|
|
|
|
+ ],
|
|
|
|
|
+ "shape": {
|
|
|
|
|
+ "columns": 6,
|
|
|
|
|
+ "rows": 5
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ "text/html": [
|
|
|
|
|
+ "<div>\n",
|
|
|
|
|
+ "<style scoped>\n",
|
|
|
|
|
+ " .dataframe tbody tr th:only-of-type {\n",
|
|
|
|
|
+ " vertical-align: middle;\n",
|
|
|
|
|
+ " }\n",
|
|
|
|
|
+ "\n",
|
|
|
|
|
+ " .dataframe tbody tr th {\n",
|
|
|
|
|
+ " vertical-align: top;\n",
|
|
|
|
|
+ " }\n",
|
|
|
|
|
+ "\n",
|
|
|
|
|
+ " .dataframe thead th {\n",
|
|
|
|
|
+ " text-align: right;\n",
|
|
|
|
|
+ " }\n",
|
|
|
|
|
+ "</style>\n",
|
|
|
|
|
+ "<table border=\"1\" class=\"dataframe\">\n",
|
|
|
|
|
+ " <thead>\n",
|
|
|
|
|
+ " <tr style=\"text-align: right;\">\n",
|
|
|
|
|
+ " <th></th>\n",
|
|
|
|
|
+ " <th>Criterion</th>\n",
|
|
|
|
|
+ " <th>Method</th>\n",
|
|
|
|
|
+ " <th>Model</th>\n",
|
|
|
|
|
+ " <th>Estimate</th>\n",
|
|
|
|
|
+ " <th>P-value</th>\n",
|
|
|
|
|
+ " <th>Pass</th>\n",
|
|
|
|
|
+ " </tr>\n",
|
|
|
|
|
+ " </thead>\n",
|
|
|
|
|
+ " <tbody>\n",
|
|
|
|
|
+ " <tr>\n",
|
|
|
|
|
+ " <th>0</th>\n",
|
|
|
|
|
+ " <td>1. Treatment -> True</td>\n",
|
|
|
|
|
+ " <td>Fisher's exact test</td>\n",
|
|
|
|
|
+ " <td>Z x T (2x2 table)</td>\n",
|
|
|
|
|
+ " <td>0.672094</td>\n",
|
|
|
|
|
+ " <td>0.487342</td>\n",
|
|
|
|
|
+ " <td>False</td>\n",
|
|
|
|
|
+ " </tr>\n",
|
|
|
|
|
+ " <tr>\n",
|
|
|
|
|
+ " <th>1</th>\n",
|
|
|
|
|
+ " <td>2. Treatment -> Surrogate</td>\n",
|
|
|
|
|
+ " <td>Kolmogorov–Smirnov test</td>\n",
|
|
|
|
|
+ " <td>S by Z groups</td>\n",
|
|
|
|
|
+ " <td>0.288515</td>\n",
|
|
|
|
|
+ " <td>0.587966</td>\n",
|
|
|
|
|
+ " <td>False</td>\n",
|
|
|
|
|
+ " </tr>\n",
|
|
|
|
|
+ " <tr>\n",
|
|
|
|
|
+ " <th>2</th>\n",
|
|
|
|
|
+ " <td>3. Surrogate -> True</td>\n",
|
|
|
|
|
+ " <td>Logistic</td>\n",
|
|
|
|
|
+ " <td>T ~ S</td>\n",
|
|
|
|
|
+ " <td>10.738159</td>\n",
|
|
|
|
|
+ " <td>0.004114</td>\n",
|
|
|
|
|
+ " <td>True</td>\n",
|
|
|
|
|
+ " </tr>\n",
|
|
|
|
|
+ " <tr>\n",
|
|
|
|
|
+ " <th>3</th>\n",
|
|
|
|
|
+ " <td>4. Full Mediation</td>\n",
|
|
|
|
|
+ " <td>Logistic</td>\n",
|
|
|
|
|
+ " <td>T ~ S + Z</td>\n",
|
|
|
|
|
+ " <td>1.034327</td>\n",
|
|
|
|
|
+ " <td>0.644192</td>\n",
|
|
|
|
|
+ " <td>True</td>\n",
|
|
|
|
|
+ " </tr>\n",
|
|
|
|
|
+ " <tr>\n",
|
|
|
|
|
+ " <th>4</th>\n",
|
|
|
|
|
+ " <td>Proportion Explained (PE)</td>\n",
|
|
|
|
|
+ " <td>Logistic coefficients</td>\n",
|
|
|
|
|
+ " <td>Compare Z in (T ~ Z) vs (T ~ S + Z).</td>\n",
|
|
|
|
|
+ " <td>-0.538962</td>\n",
|
|
|
|
|
+ " <td><NA></td>\n",
|
|
|
|
|
+ " <td>False</td>\n",
|
|
|
|
|
+ " </tr>\n",
|
|
|
|
|
+ " </tbody>\n",
|
|
|
|
|
+ "</table>\n",
|
|
|
|
|
+ "</div>"
|
|
|
|
|
+ ],
|
|
|
|
|
+ "text/plain": [
|
|
|
|
|
+ " Criterion Method \\\n",
|
|
|
|
|
+ "0 1. Treatment -> True Fisher's exact test \n",
|
|
|
|
|
+ "1 2. Treatment -> Surrogate Kolmogorov–Smirnov test \n",
|
|
|
|
|
+ "2 3. Surrogate -> True Logistic \n",
|
|
|
|
|
+ "3 4. Full Mediation Logistic \n",
|
|
|
|
|
+ "4 Proportion Explained (PE) Logistic coefficients \n",
|
|
|
|
|
+ "\n",
|
|
|
|
|
+ " Model Estimate P-value Pass \n",
|
|
|
|
|
+ "0 Z x T (2x2 table) 0.672094 0.487342 False \n",
|
|
|
|
|
+ "1 S by Z groups 0.288515 0.587966 False \n",
|
|
|
|
|
+ "2 T ~ S 10.738159 0.004114 True \n",
|
|
|
|
|
+ "3 T ~ S + Z 1.034327 0.644192 True \n",
|
|
|
|
|
+ "4 Compare Z in (T ~ Z) vs (T ~ S + Z). -0.538962 <NA> False "
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ "execution_count": 14,
|
|
|
|
|
+ "metadata": {},
|
|
|
|
|
+ "output_type": "execute_result"
|
|
|
|
|
+ }
|
|
|
|
|
+ ],
|
|
|
|
|
+ "source": [
|
|
|
|
|
+ "df_prentice2 = utils.prentice_criteria(\n",
|
|
|
|
|
+ " df_work,\n",
|
|
|
|
|
+ " endpoint=\"T\",\n",
|
|
|
|
|
+ " surrogate=\"S\",\n",
|
|
|
|
|
+ " treatment=\"Z\",\n",
|
|
|
|
|
+ " alpha=0.05,\n",
|
|
|
|
|
+ " return_models=False,\n",
|
|
|
|
|
+ " criterion1_test=\"fisher\",\n",
|
|
|
|
|
+ " criterion2_test=\"ks\",\n",
|
|
|
|
|
+ ")\n",
|
|
|
|
|
+ "\n",
|
|
|
|
|
+ "df_prentice2"
|
|
|
]
|
|
]
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
@@ -1494,7 +1709,12 @@
|
|
|
"id": "469afd91",
|
|
"id": "469afd91",
|
|
|
"metadata": {},
|
|
"metadata": {},
|
|
|
"outputs": [],
|
|
"outputs": [],
|
|
|
- "source": []
|
|
|
|
|
|
|
+ "source": [
|
|
|
|
|
+ "# storing results in an Excel file with two sheets\n",
|
|
|
|
|
+ "with pd.ExcelWriter(\"results/prentice_results.xlsx\", engine=\"openpyxl\") as writer:\n",
|
|
|
|
|
+ " df_prentice1.to_excel(writer, sheet_name=\"chi2_ks\", index=False)\n",
|
|
|
|
|
+ " df_prentice2.to_excel(writer, sheet_name=\"fisher_ks\", index=False)"
|
|
|
|
|
+ ]
|
|
|
}
|
|
}
|
|
|
],
|
|
],
|
|
|
"metadata": {
|
|
"metadata": {
|