From 4e675c7f12e9aade5d0d062a7ed6193cf4ef99e0 Mon Sep 17 00:00:00 2001 From: James Gaboardi Date: Wed, 11 Oct 2023 09:22:06 -0400 Subject: [PATCH 1/2] Update README.md correct error in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 96a592d..de306c8 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ **G**eneralized **L**inear **M**odeling ======================================= -[![Continuous Integration](https://github.com/pysal/spglm/actions/workflows/testing.yml/badge.svg)] +[![Continuous Integration](https://github.com/pysal/spglm/actions/workflows/testing.yml/badge.svg)](https://github.com/pysal/spglm/actions/workflows/testing.yml) [![Documentation Status](https://readthedocs.org/projects/spglm/badge/?version=latest)](https://spglm.readthedocs.io/en/latest/?badge=latest) [![PyPI version](https://badge.fury.io/py/spglm.svg)](https://badge.fury.io/py/spglm) From a979556ebdbc9fb4c7fc000f56536d20fd491bfe Mon Sep 17 00:00:00 2001 From: James Gaboardi Date: Wed, 11 Oct 2023 10:49:28 -0400 Subject: [PATCH 2/2] apply martin suggestion --- notebooks/Binomial_GLM.ipynb | 689 +++-------------------------------- 1 file changed, 44 insertions(+), 645 deletions(-) diff --git a/notebooks/Binomial_GLM.ipynb b/notebooks/Binomial_GLM.ipynb index e3d36fe..cd9b607 100644 --- a/notebooks/Binomial_GLM.ipynb +++ b/notebooks/Binomial_GLM.ipynb @@ -21,651 +21,50 @@ "# Load sample dataset - Subset of london house price dataset\n", "db = ps.open(ps.get_path(\"columbus.dbf\"), \"r\")\n", "\n", - "# Set dependent variable\n", - "y = np.array(\n", - " [\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 1,\n", - " 0,\n", - " 1,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 1,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 1,\n", - " 0,\n", - " 0,\n", - " 1,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 1,\n", - " 1,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 1,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 1,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 1,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 1,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 1,\n", - " 1,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 1,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 1,\n", - " 0,\n", - " 1,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 1,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 1,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 1,\n", - " 1,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 1,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 1,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 1,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 1,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 1,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 1,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 1,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 1,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " 0,\n", - " ]\n", - ")\n", - "y = y.reshape((316, 1))\n", + "#Set dependent variable\n", + "y = np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,\n", + " 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0,\n", + " 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,\n", + " 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n", + " 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,\n", + " 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n", + " 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n", + " 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,\n", + " 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1,\n", + " 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,\n", + " 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,\n", + " 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,\n", + " 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0,\n", + " 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])\n", + "y = y.reshape((316,1))\n", "\n", - "# Set independent variable (FLOORSZ)\n", - "X = np.array(\n", - " [\n", - " 77,\n", - " 75,\n", - " 64,\n", - " 95,\n", - " 107,\n", - " 100,\n", - " 81,\n", - " 151,\n", - " 98,\n", - " 260,\n", - " 171,\n", - " 161,\n", - " 91,\n", - " 80,\n", - " 50,\n", - " 85,\n", - " 52,\n", - " 69,\n", - " 60,\n", - " 84,\n", - " 155,\n", - " 97,\n", - " 69,\n", - " 126,\n", - " 90,\n", - " 43,\n", - " 51,\n", - " 41,\n", - " 140,\n", - " 80,\n", - " 52,\n", - " 86,\n", - " 66,\n", - " 60,\n", - " 40,\n", - " 155,\n", - " 138,\n", - " 97,\n", - " 115,\n", - " 148,\n", - " 206,\n", - " 60,\n", - " 53,\n", - " 96,\n", - " 88,\n", - " 160,\n", - " 31,\n", - " 43,\n", - " 154,\n", - " 60,\n", - " 131,\n", - " 60,\n", - " 46,\n", - " 61,\n", - " 125,\n", - " 150,\n", - " 76,\n", - " 92,\n", - " 96,\n", - " 100,\n", - " 105,\n", - " 72,\n", - " 48,\n", - " 41,\n", - " 72,\n", - " 65,\n", - " 60,\n", - " 65,\n", - " 98,\n", - " 33,\n", - " 144,\n", - " 111,\n", - " 91,\n", - " 108,\n", - " 38,\n", - " 48,\n", - " 95,\n", - " 63,\n", - " 98,\n", - " 129,\n", - " 108,\n", - " 51,\n", - " 131,\n", - " 66,\n", - " 48,\n", - " 127,\n", - " 76,\n", - " 68,\n", - " 52,\n", - " 64,\n", - " 57,\n", - " 121,\n", - " 67,\n", - " 76,\n", - " 112,\n", - " 96,\n", - " 90,\n", - " 53,\n", - " 93,\n", - " 64,\n", - " 97,\n", - " 58,\n", - " 44,\n", - " 157,\n", - " 53,\n", - " 70,\n", - " 71,\n", - " 167,\n", - " 47,\n", - " 70,\n", - " 96,\n", - " 77,\n", - " 75,\n", - " 71,\n", - " 67,\n", - " 47,\n", - " 71,\n", - " 90,\n", - " 69,\n", - " 64,\n", - " 65,\n", - " 95,\n", - " 60,\n", - " 60,\n", - " 65,\n", - " 54,\n", - " 121,\n", - " 105,\n", - " 50,\n", - " 85,\n", - " 69,\n", - " 69,\n", - " 62,\n", - " 65,\n", - " 93,\n", - " 93,\n", - " 70,\n", - " 62,\n", - " 155,\n", - " 68,\n", - " 117,\n", - " 80,\n", - " 80,\n", - " 75,\n", - " 98,\n", - " 114,\n", - " 86,\n", - " 70,\n", - " 50,\n", - " 51,\n", - " 163,\n", - " 124,\n", - " 59,\n", - " 95,\n", - " 51,\n", - " 63,\n", - " 85,\n", - " 53,\n", - " 46,\n", - " 102,\n", - " 114,\n", - " 83,\n", - " 47,\n", - " 40,\n", - " 63,\n", - " 123,\n", - " 100,\n", - " 63,\n", - " 110,\n", - " 79,\n", - " 98,\n", - " 99,\n", - " 120,\n", - " 52,\n", - " 48,\n", - " 37,\n", - " 81,\n", - " 30,\n", - " 88,\n", - " 50,\n", - " 35,\n", - " 116,\n", - " 67,\n", - " 45,\n", - " 80,\n", - " 86,\n", - " 109,\n", - " 59,\n", - " 75,\n", - " 60,\n", - " 71,\n", - " 141,\n", - " 121,\n", - " 50,\n", - " 168,\n", - " 90,\n", - " 51,\n", - " 133,\n", - " 75,\n", - " 133,\n", - " 127,\n", - " 37,\n", - " 68,\n", - " 105,\n", - " 61,\n", - " 123,\n", - " 151,\n", - " 110,\n", - " 77,\n", - " 220,\n", - " 94,\n", - " 77,\n", - " 70,\n", - " 100,\n", - " 98,\n", - " 126,\n", - " 55,\n", - " 105,\n", - " 60,\n", - " 176,\n", - " 104,\n", - " 68,\n", - " 62,\n", - " 70,\n", - " 48,\n", - " 102,\n", - " 80,\n", - " 97,\n", - " 66,\n", - " 80,\n", - " 102,\n", - " 160,\n", - " 55,\n", - " 60,\n", - " 71,\n", - " 125,\n", - " 85,\n", - " 85,\n", - " 190,\n", - " 137,\n", - " 48,\n", - " 41,\n", - " 42,\n", - " 51,\n", - " 57,\n", - " 60,\n", - " 114,\n", - " 88,\n", - " 84,\n", - " 108,\n", - " 66,\n", - " 85,\n", - " 42,\n", - " 98,\n", - " 90,\n", - " 127,\n", - " 100,\n", - " 55,\n", - " 76,\n", - " 82,\n", - " 63,\n", - " 80,\n", - " 71,\n", - " 76,\n", - " 121,\n", - " 109,\n", - " 92,\n", - " 160,\n", - " 109,\n", - " 185,\n", - " 100,\n", - " 90,\n", - " 90,\n", - " 86,\n", - " 88,\n", - " 95,\n", - " 116,\n", - " 135,\n", - " 61,\n", - " 74,\n", - " 60,\n", - " 235,\n", - " 76,\n", - " 66,\n", - " 100,\n", - " 49,\n", - " 50,\n", - " 37,\n", - " 100,\n", - " 88,\n", - " 90,\n", - " 52,\n", - " 95,\n", - " 81,\n", - " 79,\n", - " 96,\n", - " 75,\n", - " 91,\n", - " 86,\n", - " 83,\n", - " 180,\n", - " 108,\n", - " 80,\n", - " 96,\n", - " 49,\n", - " 117,\n", - " 117,\n", - " 86,\n", - " 46,\n", - " 66,\n", - " 95,\n", - " 57,\n", - " 120,\n", - " 137,\n", - " 68,\n", - " 240,\n", - " ]\n", - ")\n", - "X = X.reshape((316, 1))" + "#Set independent variable (FLOORSZ)\n", + "X = np.array([ 77, 75, 64, 95, 107, 100, 81, 151, 98, 260, 171, 161, 91,\n", + " 80, 50, 85, 52, 69, 60, 84, 155, 97, 69, 126, 90, 43,\n", + " 51, 41, 140, 80, 52, 86, 66, 60, 40, 155, 138, 97, 115,\n", + " 148, 206, 60, 53, 96, 88, 160, 31, 43, 154, 60, 131, 60,\n", + " 46, 61, 125, 150, 76, 92, 96, 100, 105, 72, 48, 41, 72,\n", + " 65, 60, 65, 98, 33, 144, 111, 91, 108, 38, 48, 95, 63,\n", + " 98, 129, 108, 51, 131, 66, 48, 127, 76, 68, 52, 64, 57,\n", + " 121, 67, 76, 112, 96, 90, 53, 93, 64, 97, 58, 44, 157,\n", + " 53, 70, 71, 167, 47, 70, 96, 77, 75, 71, 67, 47, 71,\n", + " 90, 69, 64, 65, 95, 60, 60, 65, 54, 121, 105, 50, 85,\n", + " 69, 69, 62, 65, 93, 93, 70, 62, 155, 68, 117, 80, 80,\n", + " 75, 98, 114, 86, 70, 50, 51, 163, 124, 59, 95, 51, 63,\n", + " 85, 53, 46, 102, 114, 83, 47, 40, 63, 123, 100, 63, 110,\n", + " 79, 98, 99, 120, 52, 48, 37, 81, 30, 88, 50, 35, 116,\n", + " 67, 45, 80, 86, 109, 59, 75, 60, 71, 141, 121, 50, 168,\n", + " 90, 51, 133, 75, 133, 127, 37, 68, 105, 61, 123, 151, 110,\n", + " 77, 220, 94, 77, 70, 100, 98, 126, 55, 105, 60, 176, 104,\n", + " 68, 62, 70, 48, 102, 80, 97, 66, 80, 102, 160, 55, 60,\n", + " 71, 125, 85, 85, 190, 137, 48, 41, 42, 51, 57, 60, 114,\n", + " 88, 84, 108, 66, 85, 42, 98, 90, 127, 100, 55, 76, 82,\n", + " 63, 80, 71, 76, 121, 109, 92, 160, 109, 185, 100, 90, 90,\n", + " 86, 88, 95, 116, 135, 61, 74, 60, 235, 76, 66, 100, 49,\n", + " 50, 37, 100, 88, 90, 52, 95, 81, 79, 96, 75, 91, 86,\n", + " 83, 180, 108, 80, 96, 49, 117, 117, 86, 46, 66, 95, 57,\n", + " 120, 137, 68, 240])\n", + "X = X.reshape((316,1))" ] }, { @@ -779,5 +178,5 @@ } }, "nbformat": 4, - "nbformat_minor": 1 + "nbformat_minor": 4 }