{"action":"opened","issue":{"url":"https://api.github.com/repos/statsmodels/statsmodels/issues/2208","labels_url":"https://api.github.com/repos/statsmodels/statsmodels/issues/2208/labels{/name}","comments_url":"https://api.github.com/repos/statsmodels/statsmodels/issues/2208/comments","events_url":"https://api.github.com/repos/statsmodels/statsmodels/issues/2208/events","html_url":"https://github.com/statsmodels/statsmodels/issues/2208","id":55422674,"number":2208,"title":"GLM domain violations with non-canonical links","user":{"login":"kshedden","id":2666691,"avatar_url":"https://avatars.githubusercontent.com/u/2666691?v=3","gravatar_id":"","url":"https://api.github.com/users/kshedden","html_url":"https://github.com/kshedden","followers_url":"https://api.github.com/users/kshedden/followers","following_url":"https://api.github.com/users/kshedden/following{/other_user}","gists_url":"https://api.github.com/users/kshedden/gists{/gist_id}","starred_url":"https://api.github.com/users/kshedden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kshedden/subscriptions","organizations_url":"https://api.github.com/users/kshedden/orgs","repos_url":"https://api.github.com/users/kshedden/repos","events_url":"https://api.github.com/users/kshedden/events{/privacy}","received_events_url":"https://api.github.com/users/kshedden/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-25T17:34:47Z","updated_at":"2015-01-25T17:34:47Z","closed_at":null,"body":"IRLS produces results with no warnings when the fitted means are outside the family domain.  It's not clear that the solution is actually an MLE or if the standard errors, etc. are meaningful.  An example is below.\r\n\r\nSee also #1932, #2037\r\n\r\n```\r\nimport statsmodels.api as sm\r\nimport numpy as np\r\n\r\nnp.random.seed(823)\r\n\r\nn = 1000\r\nexog = np.random.normal(size=(n, 3))\r\nexog[:, 0] = 1\r\n\r\ntrue_params = np.r_[-0.5, 0.1, -0.1]\r\nlin_pred = np.dot(exog, true_params)\r\n\r\nendog_mean = np.exp(lin_pred)\r\n\r\nendog = 1*(np.random.uniform(size=n) < endog_mean)\r\n\r\nlnk = sm.families.links\r\n\r\nmodel_irls = sm.GLM(endog, exog, family=sm.families.Binomial(link=lnk.log))\r\nresult_irls = model_irls.fit(method=\"IRLS\")\r\n\r\nmodel_gradient = sm.GLM(endog, exog, family=sm.families.Binomial(link=lnk.log))\r\nresult_gradient = model_gradient.fit(start_params=result_irls.params, method=\"newton\")\r\n\r\nprint(result_irls.summary())\r\nprint(result_gradient.summary())\r\n\r\nprint(\"Gradient at IRLS solution:\")\r\nprint(model_gradient.score(result_gradient.params))\r\n\r\n# Some predicted values are out of range:                                                                                 \r\nprint(result_irls.predict().max())\r\n```"}}