|
5 | 5 | "colab": {
|
6 | 6 | "name": "Testing_tutorial.ipynb",
|
7 | 7 | "provenance": [],
|
8 |
| - "authorship_tag": "ABX9TyPtNVbGG+YNd1Y6fmT37q9p", |
| 8 | + "authorship_tag": "ABX9TyMf1BmJ3RBQ2bj7TzVXgfnN", |
9 | 9 | "include_colab_link": true
|
10 | 10 | },
|
11 | 11 | "kernelspec": {
|
|
751 | 751 | {
|
752 | 752 | "cell_type": "code",
|
753 | 753 | "metadata": {
|
754 |
| - "id": "EjsXAuSdNHtc", |
755 |
| - "outputId": "70959bc1-420f-4c3c-c1b1-8983ed8dd481", |
756 | 754 | "colab": {
|
757 | 755 | "base_uri": "https://localhost:8080/",
|
758 | 756 | "height": 203
|
759 |
| - } |
| 757 | + }, |
| 758 | + "id": "EjsXAuSdNHtc", |
| 759 | + "outputId": "70959bc1-420f-4c3c-c1b1-8983ed8dd481" |
760 | 760 | },
|
761 | 761 | "source": [
|
762 | 762 | "# To read data as dataframe\n",
|
|
917 | 917 | {
|
918 | 918 | "cell_type": "code",
|
919 | 919 | "metadata": {
|
| 920 | + "colab": { |
| 921 | + "base_uri": "https://localhost:8080/", |
| 922 | + "height": 172 |
| 923 | + }, |
920 | 924 | "id": "9ez6DCbeNU3O",
|
921 |
| - "outputId": "a39cb14c-e325-4042-f49f-dd975ac9d323", |
| 925 | + "outputId": "b65c7953-59d4-4bd5-b8ec-92df9e2d7f45" |
| 926 | + }, |
| 927 | + "source": [ |
| 928 | + "model = ols('Defaultee ~ C(Gender) + C(Ethnicity) + C(Gender):C(Ethnicity)', data=data).fit()\n", |
| 929 | + "sm.stats.anova_lm(model, typ=1)" |
| 930 | + ], |
| 931 | + "execution_count": 83, |
| 932 | + "outputs": [ |
| 933 | + { |
| 934 | + "output_type": "execute_result", |
| 935 | + "data": { |
| 936 | + "text/html": [ |
| 937 | + "<div>\n", |
| 938 | + "<style scoped>\n", |
| 939 | + " .dataframe tbody tr th:only-of-type {\n", |
| 940 | + " vertical-align: middle;\n", |
| 941 | + " }\n", |
| 942 | + "\n", |
| 943 | + " .dataframe tbody tr th {\n", |
| 944 | + " vertical-align: top;\n", |
| 945 | + " }\n", |
| 946 | + "\n", |
| 947 | + " .dataframe thead th {\n", |
| 948 | + " text-align: right;\n", |
| 949 | + " }\n", |
| 950 | + "</style>\n", |
| 951 | + "<table border=\"1\" class=\"dataframe\">\n", |
| 952 | + " <thead>\n", |
| 953 | + " <tr style=\"text-align: right;\">\n", |
| 954 | + " <th></th>\n", |
| 955 | + " <th>df</th>\n", |
| 956 | + " <th>sum_sq</th>\n", |
| 957 | + " <th>mean_sq</th>\n", |
| 958 | + " <th>F</th>\n", |
| 959 | + " <th>PR(>F)</th>\n", |
| 960 | + " </tr>\n", |
| 961 | + " </thead>\n", |
| 962 | + " <tbody>\n", |
| 963 | + " <tr>\n", |
| 964 | + " <th>C(Gender)</th>\n", |
| 965 | + " <td>1.0</td>\n", |
| 966 | + " <td>0.000677</td>\n", |
| 967 | + " <td>0.000677</td>\n", |
| 968 | + " <td>0.004523</td>\n", |
| 969 | + " <td>0.946415</td>\n", |
| 970 | + " </tr>\n", |
| 971 | + " <tr>\n", |
| 972 | + " <th>C(Ethnicity)</th>\n", |
| 973 | + " <td>2.0</td>\n", |
| 974 | + " <td>0.007807</td>\n", |
| 975 | + " <td>0.003903</td>\n", |
| 976 | + " <td>0.026083</td>\n", |
| 977 | + " <td>0.974256</td>\n", |
| 978 | + " </tr>\n", |
| 979 | + " <tr>\n", |
| 980 | + " <th>C(Gender):C(Ethnicity)</th>\n", |
| 981 | + " <td>2.0</td>\n", |
| 982 | + " <td>0.069887</td>\n", |
| 983 | + " <td>0.034944</td>\n", |
| 984 | + " <td>0.233504</td>\n", |
| 985 | + " <td>0.791864</td>\n", |
| 986 | + " </tr>\n", |
| 987 | + " <tr>\n", |
| 988 | + " <th>Residual</th>\n", |
| 989 | + " <td>394.0</td>\n", |
| 990 | + " <td>58.961630</td>\n", |
| 991 | + " <td>0.149649</td>\n", |
| 992 | + " <td>NaN</td>\n", |
| 993 | + " <td>NaN</td>\n", |
| 994 | + " </tr>\n", |
| 995 | + " </tbody>\n", |
| 996 | + "</table>\n", |
| 997 | + "</div>" |
| 998 | + ], |
| 999 | + "text/plain": [ |
| 1000 | + " df sum_sq mean_sq F PR(>F)\n", |
| 1001 | + "C(Gender) 1.0 0.000677 0.000677 0.004523 0.946415\n", |
| 1002 | + "C(Ethnicity) 2.0 0.007807 0.003903 0.026083 0.974256\n", |
| 1003 | + "C(Gender):C(Ethnicity) 2.0 0.069887 0.034944 0.233504 0.791864\n", |
| 1004 | + "Residual 394.0 58.961630 0.149649 NaN NaN" |
| 1005 | + ] |
| 1006 | + }, |
| 1007 | + "metadata": {}, |
| 1008 | + "execution_count": 83 |
| 1009 | + } |
| 1010 | + ] |
| 1011 | + }, |
| 1012 | + { |
| 1013 | + "cell_type": "code", |
| 1014 | + "metadata": { |
| 1015 | + "id": "huuCaEC9OmXt", |
| 1016 | + "outputId": "48cf90e8-a45b-4e5f-d635-6265ea7b1397", |
922 | 1017 | "colab": {
|
923 | 1018 | "base_uri": "https://localhost:8080/",
|
924 | 1019 | "height": 172
|
925 | 1020 | }
|
926 | 1021 | },
|
927 | 1022 | "source": [
|
928 |
| - "model = ols('Defaultee ~ C(Gender) + C(Ethnicity) + C(Gender):C(Ethnicity)', data=data).fit()\n", |
| 1023 | + "model = ols('Defaultee ~ C(Gender) + C(Ethnicity) + C(Gender)*C(Ethnicity)', data=data).fit()\n", |
929 | 1024 | "sm.stats.anova_lm(model, typ=2)"
|
930 | 1025 | ],
|
931 |
| - "execution_count": 69, |
| 1026 | + "execution_count": 84, |
932 | 1027 | "outputs": [
|
933 | 1028 | {
|
934 | 1029 | "output_type": "execute_result",
|
|
1000 | 1095 | ]
|
1001 | 1096 | },
|
1002 | 1097 | "metadata": {},
|
1003 |
| - "execution_count": 69 |
| 1098 | + "execution_count": 84 |
| 1099 | + } |
| 1100 | + ] |
| 1101 | + }, |
| 1102 | + { |
| 1103 | + "cell_type": "code", |
| 1104 | + "metadata": { |
| 1105 | + "id": "R5NgjCsvO0oj", |
| 1106 | + "outputId": "505344f8-5701-4082-d44a-2b8d2bf8b1c2", |
| 1107 | + "colab": { |
| 1108 | + "base_uri": "https://localhost:8080/", |
| 1109 | + "height": 203 |
| 1110 | + } |
| 1111 | + }, |
| 1112 | + "source": [ |
| 1113 | + "model= ols('Defaultee ~ C(Gender)*C(Ethnicity)', data=data).fit()\n", |
| 1114 | + "sm.stats.anova_lm(model, typ=3)" |
| 1115 | + ], |
| 1116 | + "execution_count": 80, |
| 1117 | + "outputs": [ |
| 1118 | + { |
| 1119 | + "output_type": "execute_result", |
| 1120 | + "data": { |
| 1121 | + "text/html": [ |
| 1122 | + "<div>\n", |
| 1123 | + "<style scoped>\n", |
| 1124 | + " .dataframe tbody tr th:only-of-type {\n", |
| 1125 | + " vertical-align: middle;\n", |
| 1126 | + " }\n", |
| 1127 | + "\n", |
| 1128 | + " .dataframe tbody tr th {\n", |
| 1129 | + " vertical-align: top;\n", |
| 1130 | + " }\n", |
| 1131 | + "\n", |
| 1132 | + " .dataframe thead th {\n", |
| 1133 | + " text-align: right;\n", |
| 1134 | + " }\n", |
| 1135 | + "</style>\n", |
| 1136 | + "<table border=\"1\" class=\"dataframe\">\n", |
| 1137 | + " <thead>\n", |
| 1138 | + " <tr style=\"text-align: right;\">\n", |
| 1139 | + " <th></th>\n", |
| 1140 | + " <th>sum_sq</th>\n", |
| 1141 | + " <th>df</th>\n", |
| 1142 | + " <th>F</th>\n", |
| 1143 | + " <th>PR(>F)</th>\n", |
| 1144 | + " </tr>\n", |
| 1145 | + " </thead>\n", |
| 1146 | + " <tbody>\n", |
| 1147 | + " <tr>\n", |
| 1148 | + " <th>Intercept</th>\n", |
| 1149 | + " <td>1.280000</td>\n", |
| 1150 | + " <td>1.0</td>\n", |
| 1151 | + " <td>8.553359</td>\n", |
| 1152 | + " <td>0.003648</td>\n", |
| 1153 | + " </tr>\n", |
| 1154 | + " <tr>\n", |
| 1155 | + " <th>C(Gender)</th>\n", |
| 1156 | + " <td>0.048089</td>\n", |
| 1157 | + " <td>1.0</td>\n", |
| 1158 | + " <td>0.321346</td>\n", |
| 1159 | + " <td>0.571123</td>\n", |
| 1160 | + " </tr>\n", |
| 1161 | + " <tr>\n", |
| 1162 | + " <th>C(Ethnicity)</th>\n", |
| 1163 | + " <td>0.042944</td>\n", |
| 1164 | + " <td>2.0</td>\n", |
| 1165 | + " <td>0.143483</td>\n", |
| 1166 | + " <td>0.866381</td>\n", |
| 1167 | + " </tr>\n", |
| 1168 | + " <tr>\n", |
| 1169 | + " <th>C(Gender):C(Ethnicity)</th>\n", |
| 1170 | + " <td>0.069887</td>\n", |
| 1171 | + " <td>2.0</td>\n", |
| 1172 | + " <td>0.233504</td>\n", |
| 1173 | + " <td>0.791864</td>\n", |
| 1174 | + " </tr>\n", |
| 1175 | + " <tr>\n", |
| 1176 | + " <th>Residual</th>\n", |
| 1177 | + " <td>58.961630</td>\n", |
| 1178 | + " <td>394.0</td>\n", |
| 1179 | + " <td>NaN</td>\n", |
| 1180 | + " <td>NaN</td>\n", |
| 1181 | + " </tr>\n", |
| 1182 | + " </tbody>\n", |
| 1183 | + "</table>\n", |
| 1184 | + "</div>" |
| 1185 | + ], |
| 1186 | + "text/plain": [ |
| 1187 | + " sum_sq df F PR(>F)\n", |
| 1188 | + "Intercept 1.280000 1.0 8.553359 0.003648\n", |
| 1189 | + "C(Gender) 0.048089 1.0 0.321346 0.571123\n", |
| 1190 | + "C(Ethnicity) 0.042944 2.0 0.143483 0.866381\n", |
| 1191 | + "C(Gender):C(Ethnicity) 0.069887 2.0 0.233504 0.791864\n", |
| 1192 | + "Residual 58.961630 394.0 NaN NaN" |
| 1193 | + ] |
| 1194 | + }, |
| 1195 | + "metadata": {}, |
| 1196 | + "execution_count": 80 |
1004 | 1197 | }
|
1005 | 1198 | ]
|
1006 | 1199 | },
|
|
1377 | 1570 | {
|
1378 | 1571 | "cell_type": "code",
|
1379 | 1572 | "metadata": {
|
1380 |
| - "id": "dUHlcjVmt62F", |
1381 |
| - "outputId": "ae5c5672-cd04-44f8-ac4c-95981e56bf6a", |
1382 | 1573 | "colab": {
|
1383 | 1574 | "base_uri": "https://localhost:8080/"
|
1384 |
| - } |
| 1575 | + }, |
| 1576 | + "id": "dUHlcjVmt62F", |
| 1577 | + "outputId": "ae5c5672-cd04-44f8-ac4c-95981e56bf6a" |
1385 | 1578 | },
|
1386 | 1579 | "source": [
|
1387 | 1580 | "p,dof"
|
|
1403 | 1596 | {
|
1404 | 1597 | "cell_type": "code",
|
1405 | 1598 | "metadata": {
|
1406 |
| - "id": "dt9wXHeLt831", |
1407 |
| - "outputId": "8e0aecf4-f8fc-48e6-f674-705b19f65dce", |
1408 | 1599 | "colab": {
|
1409 | 1600 | "base_uri": "https://localhost:8080/"
|
1410 |
| - } |
| 1601 | + }, |
| 1602 | + "id": "dt9wXHeLt831", |
| 1603 | + "outputId": "8e0aecf4-f8fc-48e6-f674-705b19f65dce" |
1411 | 1604 | },
|
1412 | 1605 | "source": [
|
1413 | 1606 | "expected"
|
|
0 commit comments