diff --git a/README.md b/README.md index fcb199c..6bdf742 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# hdpGLM +# hdpGLM [![CRAN status](https://www.r-pkg.org/badges/version/hdpGLM?color=green)](https://cran.r-project.org/package=hdpGLM) [![](https://travis-ci.org/DiogoFerrari/hdpGLM.svg)](https://travis-ci.org/DiogoFerrari/hdpGLM) diff --git a/docs/articles/hdpGLM.html b/docs/articles/hdpGLM.html index 1a48414..e212675 100644 --- a/docs/articles/hdpGLM.html +++ b/docs/articles/hdpGLM.html @@ -162,7 +162,7 @@
The summary function prints the result in a tidy format. The column k
in the summary shows the label of the estimated clusters. The column Mean
is the average of the posterior distribution for each linear coefficient in each cluster.
There are a series of built-in functions, with various options, to plot the results. In the example below, you see two of those options. The separate
parameter plot the posterior samples for each cluster separately, and the option ncols
controls how many columns to use for the panels in the figure (to see more, run help(plot.hdpGLM)
and help(plot.dpGLM)
).
@@ -264,7 +264,7 @@Estimating Context-de #> Number of clusters (summary across contexts): #> #> Average Std.Dev Median Min. Max. -#> 1 6 1.581139 6 4 8 +#> 1 3.8 1.095445 4 2 5 #> -------------------------------- #> #> @@ -273,159 +273,115 @@
Estimating Context-de #> -------------------------------- #> Coefficients and clusters for context 1 #> -#> Post.Mean Post.Median HPD.lower HPD.upper Cluster -#> 1 (Intercept) -3.8435408 -3.8331510 -3.97615472 -3.7537721 1 -#> 2 inequality -1.3261029 -1.4901385 -1.60901140 0.1909329 1 -#> 3 income 3.9066994 3.8943490 3.82972320 4.0263987 1 -#> 4 ideology -8.2611514 -8.2624920 -8.33710096 -8.1455290 1 -#> 5 (Intercept) -4.1654905 -4.0462736 -4.69968653 -3.8005696 2 -#> 6 inequality 1.4334157 1.8348051 -0.05470515 2.0414495 2 -#> 7 income 3.2182141 3.7806349 1.36860779 3.9024854 2 -#> 8 ideology -8.4188022 -8.3177074 -9.17621538 -8.1796062 2 -#> 9 (Intercept) -3.7734976 -3.7792676 -3.92427463 -3.6115441 4 -#> 10 inequality 2.1559495 2.1683449 1.77261760 2.4698304 4 -#> 11 income 3.7756314 3.9057743 2.39785208 3.9984130 4 -#> 12 ideology -8.4067996 -8.3653046 -8.79600576 -8.2157451 4 -#> 13 (Intercept) -1.6294115 -1.9283983 -2.97297752 2.6425719 9 -#> 14 inequality 0.2594955 0.3268137 -2.65567556 1.8628584 9 -#> 15 income 3.2532009 3.5737939 0.37857368 4.5539295 9 -#> 16 ideology -8.3468020 -8.2634402 -9.35668914 -7.3552482 9 +#> Post.Mean Post.Median HPD.lower HPD.upper Cluster +#> 1 (Intercept) -3.761428 -3.771248 -3.864421 -3.5027048 1 +#> 2 inequality -1.484083 -1.534678 -1.616683 -0.7499711 1 +#> 3 income 3.879462 3.882396 3.774988 3.9886461 1 +#> 4 ideology -8.257659 -8.269118 -8.380857 -8.0369345 1 +#> 5 (Intercept) -3.689410 -3.594898 -4.073907 -3.4777484 3 +#> 6 inequality 2.132635 2.152062 1.949586 2.2339621 3 +#> 7 income 3.875721 3.897136 3.694955 3.9638789 3 +#> 8 ideology -8.395083 -8.398066 -8.549199 -8.1152613 3 +#> 9 (Intercept) -4.135991 -4.119915 -4.519042 -3.9419748 4 +#> 10 inequality 1.837423 1.838560 1.611611 2.0460127 4 +#> 11 income 3.780745 3.786486 3.492423 4.0138943 4 +#> 12 ideology -8.212079 -8.284959 -8.498787 -7.5438859 4 +#> 13 (Intercept) -3.585939 -3.580628 -3.999386 -3.3275176 6 +#> 14 inequality 2.297557 2.273355 1.958788 2.8820032 6 +#> 15 income 4.316107 4.352829 3.712140 4.7519718 6 +#> 16 ideology -7.103224 -7.172574 -7.502413 -6.5254658 6 #> #> -------------------------------- -#> Coefficients and clusters for context 2 +#> Coefficients and clusters for context 3 #> #> Post.Mean Post.Median HPD.lower HPD.upper Cluster -#> 1 (Intercept) 0.51517881 0.36982828 -1.1130717 3.30249080 1 -#> 2 inequality -0.45557980 -0.20228041 -4.5808496 1.19173373 1 -#> 3 income -0.23081965 0.13507036 -6.4076499 1.09119173 1 -#> 4 ideology -1.99271658 -1.82966055 -4.1611936 4.26886540 1 -#> 5 (Intercept) 0.52389369 0.45962310 0.2398841 1.05539241 2 -#> 6 inequality -1.14002268 -0.98920628 -2.3117589 -0.76755352 2 -#> 7 income 2.08428502 2.01491051 1.8084943 2.93497029 2 -#> 8 ideology -1.35643411 -1.49235789 -1.6937644 0.01399451 2 -#> 9 (Intercept) -0.08153898 -0.14729049 -1.0246796 1.15942831 3 -#> 10 inequality 0.94896101 0.94429845 0.2015474 1.81448360 3 -#> 11 income -0.38343117 -0.29268862 -2.1449640 0.26683443 3 -#> 12 ideology -0.96905307 -1.22408914 -2.0249429 2.39941207 3 -#> 13 (Intercept) -0.28342929 -0.25251476 -1.0816921 0.04286750 5 -#> 14 inequality -1.39204865 -1.33632204 -2.3874876 -1.07728801 5 -#> 15 income -0.59661544 -0.56389919 -1.0997142 -0.31865697 5 -#> 16 ideology -2.19548561 -2.42322731 -2.5587404 0.68848760 5 -#> 17 (Intercept) 1.12505164 1.27700303 -0.8627735 1.53019849 6 -#> 18 inequality 0.88482857 0.94888981 -0.2893567 1.14176656 6 -#> 19 income 0.84726425 0.85747370 0.3982322 1.10390156 6 -#> 20 ideology -1.47622400 -1.76979768 -2.0274940 2.90507937 6 -#> 21 (Intercept) -0.06257288 0.24009197 -3.5631537 1.09447357 8 -#> 22 inequality -1.81240073 -1.65072309 -2.7426522 -1.19761110 8 -#> 23 income -0.84998923 -1.19613474 -1.6119598 1.49553415 8 -#> 24 ideology -1.89030882 -1.79190882 -3.5228788 -1.17520153 8 -#> 25 (Intercept) -0.66600743 -0.62652090 -2.7758009 0.62286584 9 -#> 26 inequality -1.52015838 -1.53887343 -4.0228883 0.79006614 9 -#> 27 income 0.30017208 0.24313952 -3.2089231 3.26031261 9 -#> 28 ideology -2.46547313 -2.66935554 -9.1347461 1.31292225 9 -#> 29 (Intercept) -0.19615868 0.02584415 -4.4148130 2.33270769 10 -#> 30 inequality -1.12077777 -0.96591307 -3.6755876 1.15610225 10 -#> 31 income 0.01800805 0.03644266 -1.3027596 1.97109753 10 -#> 32 ideology -1.04117294 -1.10409139 -3.1644595 1.56493757 10 +#> 1 (Intercept) -1.01972494 -0.9502500 -3.5698961 0.17614910 2 +#> 2 inequality 0.33566451 0.6475783 -4.3723765 2.23232802 2 +#> 3 income -3.42609029 -3.6012512 -4.4005961 -1.84963000 2 +#> 4 ideology 0.02743495 1.0186052 -9.8687885 1.40664539 2 +#> 5 (Intercept) 0.27407288 0.6057320 -2.9319293 2.61216520 5 +#> 6 inequality 0.81914713 1.0496694 -3.2244425 4.55745982 5 +#> 7 income -1.95008265 -1.9142603 -7.8228012 1.12474710 5 +#> 8 ideology 0.79326369 0.8439503 -0.9768162 4.43579468 5 +#> 9 (Intercept) -0.21247282 -0.2154776 -0.4095234 0.06000963 6 +#> 10 inequality -0.59965740 -0.5757999 -0.7782928 -0.29451913 6 +#> 11 income -3.96004968 -4.0120927 -4.3278624 -3.63306485 6 +#> 12 ideology 0.74858027 0.6543076 0.4656465 1.39574302 6 +#> 13 (Intercept) -0.40891219 -0.1665331 -2.0543362 0.71347786 7 +#> 14 inequality 0.33519509 0.4952928 -0.9007382 0.78363120 7 +#> 15 income -3.13908189 -3.1348601 -4.1975067 -2.09945118 7 +#> 16 ideology 1.55395606 2.1930328 -2.5837170 2.64629105 7 #> #> -------------------------------- #> Coefficients and clusters for context 4 #> -#> Post.Mean Post.Median HPD.lower HPD.upper Cluster -#> 1 (Intercept) -0.73169442 -0.9037980 -1.1013846 0.02095586 2 -#> 2 inequality -1.43295067 -1.1818594 -2.1454116 -1.05185860 2 -#> 3 income -2.19496354 -2.1967887 -2.4152972 -1.92226657 2 -#> 4 ideology -0.32657228 -0.4105017 -0.5678483 0.05895695 2 -#> 5 (Intercept) 0.30496453 0.3074959 0.1375807 0.50958599 3 -#> 6 inequality -0.97712826 -0.9698720 -1.1711130 -0.80950998 3 -#> 7 income -2.52909758 -2.5380155 -2.7778165 -2.28215864 3 -#> 8 ideology -0.65522072 -0.6180790 -1.7552076 -0.18595031 3 -#> 9 (Intercept) -0.82320049 -0.5636055 -2.7392664 0.01507585 4 -#> 10 inequality -0.70580192 -0.6398551 -2.6985684 0.54406905 4 -#> 11 income -2.88178379 -3.1539417 -3.5607514 -1.37349445 4 -#> 12 ideology -0.27218048 -0.1219527 -1.0505935 0.17477572 4 -#> 13 (Intercept) -0.07288973 -0.1241986 -0.5169159 0.33336338 5 -#> 14 inequality -1.47828818 -1.4600679 -1.8922423 -1.13063116 5 -#> 15 income -2.75122165 -2.7351810 -3.1753430 -2.34791485 5 -#> 16 ideology 0.36634080 0.4262114 -0.4475449 0.69993376 5 -#> 17 (Intercept) -0.84468338 -0.3447709 -4.7801772 0.75100507 6 -#> 18 inequality 2.23500247 2.1281864 -2.0873087 5.44966683 6 -#> 19 income -1.72149327 -2.6214383 -4.1903446 5.03939343 6 -#> 20 ideology 0.63702113 0.8832615 -4.7261404 3.37890339 6 -#> 21 (Intercept) 0.63612631 0.6218067 -1.8050652 1.12838455 8 -#> 22 inequality -1.04446505 -0.8454189 -2.6105068 -0.33908151 8 -#> 23 income -2.19520750 -2.5450627 -3.2433446 0.13591487 8 -#> 24 ideology 0.39650249 0.5418948 -0.1688364 1.03508159 8 +#> Post.Mean Post.Median HPD.lower HPD.upper Cluster +#> 1 (Intercept) 0.08458388 0.1036253 -0.10656874 0.26854517 2 +#> 2 inequality -1.24351101 -1.1234950 -1.73284993 -0.96408102 2 +#> 3 income -2.65917476 -2.6207384 -3.01106324 -2.47416175 2 +#> 4 ideology 0.17112921 0.1936271 -0.09124850 0.38057911 2 +#> 5 (Intercept) -0.11995853 -0.1332263 -0.45516307 0.22772784 3 +#> 6 inequality -0.42929930 -0.3420012 -1.03889211 -0.10322987 3 +#> 7 income -3.28779886 -3.3342870 -5.04496876 -3.04179163 3 +#> 8 ideology -1.55452088 -1.6054922 -2.63135390 -1.21171503 3 +#> 9 (Intercept) 0.56821304 0.5654671 -0.06006991 6.87520087 5 +#> 10 inequality -0.21440090 -0.3584463 -1.57828907 2.01061143 5 +#> 11 income -2.83550116 -2.8284259 -5.04087800 -2.33390705 5 +#> 12 ideology -0.51575757 -0.3123377 -2.50613175 1.36176785 5 +#> 13 (Intercept) 0.15182891 0.1093422 -0.57155433 0.65422756 6 +#> 14 inequality -1.34700826 -1.4510370 -1.70968255 0.27885980 6 +#> 15 income -2.54424248 -2.4895309 -2.98312733 -1.87148575 6 +#> 16 ideology -0.94517802 -0.8977156 -1.36595531 -0.04142274 6 #> #> -------------------------------- -#> Coefficients and clusters for context 3 +#> Coefficients and clusters for context 5 #> -#> Post.Mean Post.Median HPD.lower HPD.upper Cluster -#> 1 (Intercept) -0.25926953 -0.19820173 -0.8816599 0.03342723 3 -#> 2 inequality 0.78949978 0.64948395 0.5068128 1.55336311 3 -#> 3 income -2.85449611 -2.74641691 -3.3410792 -2.59413200 3 -#> 4 ideology 2.30467376 2.47924176 0.8218901 2.66171271 3 -#> 5 (Intercept) -1.23877840 -1.18551761 -3.2578749 -0.54258564 4 -#> 6 inequality -1.65628941 -1.27929729 -5.5054353 -0.94653243 4 -#> 7 income -3.87005921 -3.60267799 -4.7326358 -2.94788794 4 -#> 8 ideology 0.70516584 0.54238621 0.2423656 2.75080495 4 -#> 9 (Intercept) -0.39154150 -0.42097471 -2.2758667 0.97352390 5 -#> 10 inequality 1.85820726 1.69308566 -0.2560587 5.43778542 5 -#> 11 income -3.40348888 -3.57881612 -3.8411959 3.14998154 5 -#> 12 ideology 0.84778008 1.18706324 -2.6682937 2.33590577 5 -#> 13 (Intercept) -1.60223761 -1.71800492 -3.6047634 3.02291795 6 -#> 14 inequality -0.30337093 -0.21030377 -3.7006471 2.47982950 6 -#> 15 income -3.22913871 -3.32121285 -4.9993828 4.10891333 6 -#> 16 ideology 0.86996488 0.73873960 -1.3419990 5.59434670 6 -#> 17 (Intercept) -0.08123915 -0.07360822 -0.3040332 0.13814669 7 -#> 18 inequality -0.46931615 -0.45660556 -0.7247035 -0.24120807 7 -#> 19 income -3.90040841 -3.92053592 -4.1540293 -3.58396193 7 -#> 20 ideology 0.82768350 0.79159576 0.5023551 1.21020385 7 +#> Post.Mean Post.Median HPD.lower HPD.upper Cluster +#> 1 (Intercept) -0.41076706 -0.42330112 -0.62709533 -0.228722047 2 +#> 2 inequality -1.90652980 -1.98379960 -2.41419022 -0.778159910 2 +#> 3 income 0.35921257 0.30631446 -0.09367145 0.974484572 2 +#> 4 ideology -0.60789102 -0.68681736 -1.15577145 0.013986403 2 +#> 5 (Intercept) -0.78556490 -0.72162660 -2.42877100 -0.572660814 4 +#> 6 inequality 0.61748017 0.72212411 -3.70521945 1.460257673 4 +#> 7 income -0.01009737 -0.06005723 -1.78212427 1.960554064 4 +#> 8 ideology -0.96783199 -0.97602856 -1.28083761 -0.153856716 4 +#> 9 (Intercept) -0.18284453 -0.16682425 -0.76590308 0.162066888 7 +#> 10 inequality 0.20182834 0.42979510 -0.68526959 0.915967609 7 +#> 11 income -0.99309544 -1.06376202 -1.81417075 0.009949559 7 +#> 12 ideology -1.99955938 -1.99192948 -2.38325066 -1.563746292 7 +#> 13 (Intercept) 0.08793006 0.15532892 -0.50444659 0.608187508 8 +#> 14 inequality 1.37162265 1.36445799 0.89161439 1.638011301 8 +#> 15 income -0.06733220 -0.10184715 -1.23457889 1.068965427 8 +#> 16 ideology -2.27355841 -2.27660165 -2.65535749 -1.974109528 8 +#> 17 (Intercept) 0.14827057 0.18719294 -1.51269874 1.202668238 10 +#> 18 inequality -2.72308234 -2.82317889 -3.19663915 0.094871656 10 +#> 19 income 0.04018461 -0.13301824 -0.42411609 2.214531168 10 +#> 20 ideology -2.65614903 -2.41344511 -6.70097257 -2.177476268 10 #> #> -------------------------------- -#> Coefficients and clusters for context 5 +#> Coefficients and clusters for context 2 #> -#> Post.Mean Post.Median HPD.lower HPD.upper Cluster -#> 1 (Intercept) -1.4230080 -1.5321705 -5.8839698 0.661614331 3 -#> 2 inequality -1.0037273 -0.5778022 -4.0309941 1.938385162 3 -#> 3 income -1.4495888 -1.4399573 -7.2817562 1.303123917 3 -#> 4 ideology -1.4762405 -1.1722886 -4.9055396 2.085237802 3 -#> 5 (Intercept) 0.5974113 0.5996596 0.4375301 0.806622644 4 -#> 6 inequality -3.2824664 -3.2509196 -3.7445584 -3.016684375 4 -#> 7 income -0.6024051 -0.6293511 -1.0480435 -0.076555141 4 -#> 8 ideology -2.3373070 -2.3415567 -2.6098938 -1.881150575 4 -#> 9 (Intercept) -0.1495733 -0.1006644 -0.8479257 0.244119622 6 -#> 10 inequality -2.2764331 -2.4231700 -2.6857205 -0.912810232 6 -#> 11 income 0.2495686 0.2128931 -0.2357286 0.930641607 6 -#> 12 ideology -2.4631179 -2.3664796 -3.5038423 -2.053526800 6 -#> 13 (Intercept) 1.5639364 1.3737555 0.8902776 3.201790814 7 -#> 14 inequality 1.0824862 1.1268703 0.3697653 1.556852243 7 -#> 15 income -1.9043067 -1.9180961 -3.1397485 -0.339659631 7 -#> 16 ideology -1.8219555 -1.8295541 -2.3864767 -1.301599260 7 -#> 17 (Intercept) -0.3492777 -0.2368883 -1.6480603 0.052455567 8 -#> 18 inequality 0.8690288 0.9025359 0.3899188 1.151068730 8 -#> 19 income -0.2230016 -0.2288693 -0.6186030 0.051196600 8 -#> 20 ideology -1.6768671 -1.8276805 -2.2241845 -0.001043684 8 -#> 21 (Intercept) -0.5236535 -0.5162855 -1.6781679 0.352866511 9 -#> 22 inequality 0.2863078 0.5151032 -1.8217861 1.240399405 9 -#> 23 income -0.1754565 -0.0660489 -1.4071954 0.977147222 9 -#> 24 ideology -2.5897118 -2.4460167 -3.5903491 -1.641755515 9 -#> 25 (Intercept) 1.1040340 1.3959161 -4.8030769 4.915629556 10 -#> 26 inequality -1.6883346 -2.1510346 -6.2685254 4.878065344 10 -#> 27 income -0.3298004 -0.1037712 -7.8493782 3.596276474 10 -#> 28 ideology -1.2344563 -1.4435882 -6.0020544 4.321253399 10 +#> Post.Mean Post.Median HPD.lower HPD.upper Cluster +#> 1 (Intercept) -0.3332670 -0.2375420 -1.2300398 0.1010372 5 +#> 2 inequality -0.9952596 -1.2094112 -1.3972550 0.8999371 5 +#> 3 income -0.8110271 -0.6635803 -1.8099203 -0.4055808 5 +#> 4 ideology -2.3403821 -2.3317696 -2.8667931 -2.0694808 5 +#> 5 (Intercept) 1.2439450 1.1895780 0.8763158 2.0797700 8 +#> 6 inequality 0.8837189 0.9020004 0.4189504 1.1298293 8 +#> 7 income 0.9167082 0.9062979 0.7038610 1.1823324 8 +#> 8 ideology -1.6807154 -1.6481445 -2.2645260 -1.2892940 8 #> #> -------------------------------- #> Context-level coefficients: -#> Description Post.Mean HPD.lower HPD.upper -#> 1 Intercept of beta[0] -0.89116782 -3.738900 1.014190 -#> 2 Intercept of beta[1] -0.04422762 -3.386908 2.312727 -#> 3 Intercept of beta[2] -0.27283941 -3.895699 2.922150 -#> 4 Intercept of beta[3] -1.36146719 -4.077107 1.787112 -#> 5 Effect of gap on beta[0] -0.43612976 -2.538018 1.701550 -#> 6 Effect of gap on beta[1] 0.35448946 -1.709326 3.250508 -#> 7 Effect of gap on beta[2] -0.55377612 -3.046532 1.279999 -#> 8 Effect of gap on beta[3] 0.51181063 -1.655892 2.477581 +#> Description Post.Mean HPD.lower HPD.upper +#> 1 Intercept of beta[0] -0.711431821 -3.212432 2.236799 +#> 2 Intercept of beta[1] -0.214301686 -2.339976 3.165643 +#> 3 Intercept of beta[2] -0.105059321 -2.983060 2.039523 +#> 4 Intercept of beta[3] -1.188760896 -3.757565 1.277457 +#> 5 Effect of gap on beta[0] -0.001364097 -1.936352 2.560545 +#> 6 Effect of gap on beta[1] 0.607483773 -1.305599 2.242967 +#> 7 Effect of gap on beta[2] -0.931682076 -3.097443 1.350784 +#> 8 Effect of gap on beta[3] 0.515862538 -1.191230 2.198659 #> #> --------------------------------
The summary
contains more information now. As before, the column k
indicates the estimated clusters. The column j
indicates the country (context) of the estimated value for the respective cluster’s coefficient. The second summary ($tau
) shows the marginal effect of the context-level feature (gap
). Details of the interpretation can be found in Ferrari (2020).