{"action":"created","issue":{"url":"https://api.github.com/repos/statsmodels/statsmodels/issues/3291","repository_url":"https://api.github.com/repos/statsmodels/statsmodels","labels_url":"https://api.github.com/repos/statsmodels/statsmodels/issues/3291/labels{/name}","comments_url":"https://api.github.com/repos/statsmodels/statsmodels/issues/3291/comments","events_url":"https://api.github.com/repos/statsmodels/statsmodels/issues/3291/events","html_url":"https://github.com/statsmodels/statsmodels/pull/3291","id":191453314,"number":3291,"title":"[MRG] Add MANOVA class","user":{"login":"yl565","id":15843826,"avatar_url":"https://avatars.githubusercontent.com/u/15843826?v=3","gravatar_id":"","url":"https://api.github.com/users/yl565","html_url":"https://github.com/yl565","followers_url":"https://api.github.com/users/yl565/followers","following_url":"https://api.github.com/users/yl565/following{/other_user}","gists_url":"https://api.github.com/users/yl565/gists{/gist_id}","starred_url":"https://api.github.com/users/yl565/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yl565/subscriptions","organizations_url":"https://api.github.com/users/yl565/orgs","repos_url":"https://api.github.com/users/yl565/repos","events_url":"https://api.github.com/users/yl565/events{/privacy}","received_events_url":"https://api.github.com/users/yl565/received_events","type":"User","site_admin":false},"labels":[{"id":423319411,"url":"https://api.github.com/repos/statsmodels/statsmodels/labels/comp-multivariate","name":"comp-multivariate","color":"ededed","default":false},{"id":142961,"url":"https://api.github.com/repos/statsmodels/statsmodels/labels/type-enh","name":"type-enh","color":"99ffff","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":80,"created_at":"2016-11-24T07:50:32Z","updated_at":"2016-12-14T21:12:30Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/statsmodels/statsmodels/pulls/3291","html_url":"https://github.com/statsmodels/statsmodels/pull/3291","diff_url":"https://github.com/statsmodels/statsmodels/pull/3291.diff","patch_url":"https://github.com/statsmodels/statsmodels/pull/3291.patch"},"body":"PR as discussed in #3274. \r\nTested with a SAS example and a R example, produced the same results.\r\n\r\nTo-do:\r\n- [X] Core stats computation\r\n- [x] api\r\n- [x] automatic create dummy variable and hypothesis testing for categorical type independent variables.\r\n- [x] Input validation\r\n- [x] More examples to be tested\r\n\r\nAbout package agreement:\r\n## manova.py and test_manova.py\r\nReference:\r\n[1] MANOVA Algorithms ftp://public.dhe.ibm.com/software/analytics/spss/documentation/statistics/20.0/en/client/Manuals/IBM_SPSS_Statistics_Algorithms.pdf\r\n\r\nThey reproduces the following R code:\r\n\r\n```R\r\nDrug = c('Morphine', 'Morphine', 'Morphine', 'Morphine', 'Morphine', 'placebo', 'placebo', 'placebo', 'placebo', 'placebo', 'Trimethaphan', 'Trimethaphan', 'Trimethaphan', 'Trimethaphan', 'Trimethaphan')\r\nDepleted = c('N', 'N', 'N', 'N', 'Y', 'Y', 'Y', 'N', 'N', 'N', 'N', 'Y', 'Y', 'Y', 'Y')\r\nsubject  = c(1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)\r\nHistamine0 = c(-3.218876, -3.912023, -2.65926, -1.771957, -2.302585, -2.65926, -2.995732, -3.506558, -3.506558, -2.65926, -2.407946, -2.302585, -2.525729, -2.040221, -2.813411)\r\nHistamine1 = c(-1.609438, -2.813411, 0.336472, -0.562119, -2.407946, -2.65926, -2.65926, -0.478036, 0.04879, -0.18633, 1.141033, -2.407946, -2.407946, -2.302585, -2.995732)\r\nHistamine3 = c(-2.302585, -3.912023, -0.733969, -1.049822, -2.040221, -2.813411, -2.813411, -1.171183, -0.314711, 0.067659, 0.722706, -2.407946, -2.407946, -2.120264, -2.995732)\r\nHistamine5 = c(-2.525729, -3.912023, -1.427116, -1.427116, -1.966113, -2.65926, -2.65926, -1.514128, -0.510826, -0.223144, 0.207014, -2.525729, -2.302585, -2.120264, -2.995732)\r\ndata = data.frame(Histamine0, Histamine1, Histamine3, Histamine5)\r\nhismat = as.matrix(data[,1:4])\r\nresult = lm(hismat ~ Drug * Depleted)\r\nanova(result)\r\n```\r\n\r\n## _MultivariateOLS.py and test_MultivariateOLS.py\r\nreferences: \r\n[1] https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_introreg_sect012.htm) \r\n[2] GLM Algorithms ftp://public.dhe.ibm.com/software/analytics/spss/documentation/statistics/20.0/en/client/Manuals/IBM_SPSS_Statistics_Algorithms.pdf\r\n[3] http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.278.6976&rep=rep1&type=pdf\r\nThey reproduces results from the following R code:\r\n```R\r\nlibrary(car)\r\nDrug = c('Morphine', 'Morphine', 'Morphine', 'Morphine', 'Morphine', 'placebo', 'placebo', 'placebo', 'placebo', 'placebo', 'Trimethaphan', 'Trimethaphan', 'Trimethaphan', 'Trimethaphan', 'Trimethaphan')\r\nDepleted = c('N', 'N', 'N', 'N', 'Y', 'Y', 'Y', 'N', 'N', 'N', 'N', 'Y', 'Y', 'Y', 'Y')\r\nsubject  = c(1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)\r\nHistamine0 = c(-3.218876, -3.912023, -2.65926, -1.771957, -2.302585, -2.65926, -2.995732, -3.506558, -3.506558, -2.65926, -2.407946, -2.302585, -2.525729, -2.040221, -2.813411)\r\nHistamine1 = c(-1.609438, -2.813411, 0.336472, -0.562119, -2.407946, -2.65926, -2.65926, -0.478036, 0.04879, -0.18633, 1.141033, -2.407946, -2.407946, -2.302585, -2.995732)\r\nHistamine3 = c(-2.302585, -3.912023, -0.733969, -1.049822, -2.040221, -2.813411, -2.813411, -1.171183, -0.314711, 0.067659, 0.722706, -2.407946, -2.407946, -2.120264, -2.995732)\r\nHistamine5 = c(-2.525729, -3.912023, -1.427116, -1.427116, -1.966113, -2.65926, -2.65926, -1.514128, -0.510826, -0.223144, 0.207014, -2.525729, -2.302585, -2.120264, -2.995732)\r\ndata = data.frame(Histamine0, Histamine1, Histamine3, Histamine5)\r\nhismat = as.matrix(data[,1:4])\r\nresult = lm(hismat ~ Drug * Depleted)\r\n# Or Anova(result, type=3)\r\nlinearHypothesis(result, c(1, 0, 0, 0, 0, 0)) \r\nlinearHypothesis(result, t(cbind(c(0, 1, 0, 0, 0, 0), c(0, 0, 1, 0, 0, 0))))\r\nlinearHypothesis(result, c(0, 0, 0, 1, 0, 0)) \r\nlinearHypothesis(result, t(cbind(c(0, 0, 0, 0, 1, 0), c(0, 0, 0, 0, 0, 1))))\r\n```\r\n\r\n \r\n"},"comment":{"url":"https://api.github.com/repos/statsmodels/statsmodels/issues/comments/267158034","html_url":"https://github.com/statsmodels/statsmodels/pull/3291#issuecomment-267158034","issue_url":"https://api.github.com/repos/statsmodels/statsmodels/issues/3291","id":267158034,"user":{"login":"josef-pkt","id":440735,"avatar_url":"https://avatars.githubusercontent.com/u/440735?v=3","gravatar_id":"","url":"https://api.github.com/users/josef-pkt","html_url":"https://github.com/josef-pkt","followers_url":"https://api.github.com/users/josef-pkt/followers","following_url":"https://api.github.com/users/josef-pkt/following{/other_user}","gists_url":"https://api.github.com/users/josef-pkt/gists{/gist_id}","starred_url":"https://api.github.com/users/josef-pkt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josef-pkt/subscriptions","organizations_url":"https://api.github.com/users/josef-pkt/orgs","repos_url":"https://api.github.com/users/josef-pkt/repos","events_url":"https://api.github.com/users/josef-pkt/events{/privacy}","received_events_url":"https://api.github.com/users/josef-pkt/received_events","type":"User","site_admin":false},"created_at":"2016-12-14T21:12:30Z","updated_at":"2016-12-14T21:12:30Z","body":"Ok, if you are not sure about the math of the current MANOVA fit, then do this.\r\n\r\nI looked briefly at the SPSS manual. Their derivation is based on the cell means representation and directly assumes categorical variables (MANOVA in a narrow sense). I assume that there is an equivalent representation for the more general case, but I don't see it right away and would take too long to derive all the math. Stata also uses multivariate regression for MANOVA and their description looks like the same formulas as in SAS.\r\n\r\nUsing MultivariateOLS fit is safer because it is designed for the general case, and we don't have to worry that the QR/SPSS solution only works for a restricted set of models. "}}
{"actor":{"display_login":"josef-pkt"}}