{"action":"created","issue":{"url":"https://api.github.com/repos/CamDavidsonPilon/lifelines/issues/186","labels_url":"https://api.github.com/repos/CamDavidsonPilon/lifelines/issues/186/labels{/name}","comments_url":"https://api.github.com/repos/CamDavidsonPilon/lifelines/issues/186/comments","events_url":"https://api.github.com/repos/CamDavidsonPilon/lifelines/issues/186/events","html_url":"https://github.com/CamDavidsonPilon/lifelines/issues/186","id":107419480,"number":186,"title":"Nelson Aalen hazard off by a factor of 1/2","user":{"login":"bradhackinen","id":14437616,"avatar_url":"https://avatars.githubusercontent.com/u/14437616?v=3","gravatar_id":"","url":"https://api.github.com/users/bradhackinen","html_url":"https://github.com/bradhackinen","followers_url":"https://api.github.com/users/bradhackinen/followers","following_url":"https://api.github.com/users/bradhackinen/following{/other_user}","gists_url":"https://api.github.com/users/bradhackinen/gists{/gist_id}","starred_url":"https://api.github.com/users/bradhackinen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradhackinen/subscriptions","organizations_url":"https://api.github.com/users/bradhackinen/orgs","repos_url":"https://api.github.com/users/bradhackinen/repos","events_url":"https://api.github.com/users/bradhackinen/events{/privacy}","received_events_url":"https://api.github.com/users/bradhackinen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-20T21:40:47Z","updated_at":"2015-09-21T00:04:52Z","closed_at":null,"body":"I've been experimenting with Lifelines for hazard rate estimation, and I'm pretty sure there is a problem with the output of the Nelson Aalen fitter's hazard rate function. It looks like the function is scaled by 1/2 relative to the correct value.\r\n\r\nHere is a quick test script. The data is exponentially distributed, so it should have a constant hazard of 1. But the output (at least on my computer) shows the hazard at 0.5. \r\n\r\n```python\r\nimport pandas as pd\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nimport lifelines\r\nimport random\r\n\r\n\r\nn = 1000\r\n\r\ntestData = pd.DataFrame(index=range(n))\r\ntestData['duration'] = np.random.exponential(1,(n,))\r\n\r\n\r\nb = 1\r\nnaf = lifelines.NelsonAalenFitter()\r\nnaf.fit(testData['duration'])\r\nax = naf.plot_hazard(bandwidth=b)\r\n\r\nplt.show()\r\n```\r\n\r\n![nelsonaalenhazardtest](https://cloud.githubusercontent.com/assets/14437616/9983026/067d26ec-5fa5-11e5-8a4a-918f02e4ed72.png)\r\n\r\nIt would also be nice if the smoothed curve didn't average in some zeros at the start. That initial short increase is not coming from the data (it changes with the bandwidth).\r\n"},"comment":{"url":"https://api.github.com/repos/CamDavidsonPilon/lifelines/issues/comments/141846510","html_url":"https://github.com/CamDavidsonPilon/lifelines/issues/186#issuecomment-141846510","issue_url":"https://api.github.com/repos/CamDavidsonPilon/lifelines/issues/186","id":141846510,"user":{"login":"CamDavidsonPilon","id":884032,"avatar_url":"https://avatars.githubusercontent.com/u/884032?v=3","gravatar_id":"","url":"https://api.github.com/users/CamDavidsonPilon","html_url":"https://github.com/CamDavidsonPilon","followers_url":"https://api.github.com/users/CamDavidsonPilon/followers","following_url":"https://api.github.com/users/CamDavidsonPilon/following{/other_user}","gists_url":"https://api.github.com/users/CamDavidsonPilon/gists{/gist_id}","starred_url":"https://api.github.com/users/CamDavidsonPilon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CamDavidsonPilon/subscriptions","organizations_url":"https://api.github.com/users/CamDavidsonPilon/orgs","repos_url":"https://api.github.com/users/CamDavidsonPilon/repos","events_url":"https://api.github.com/users/CamDavidsonPilon/events{/privacy}","received_events_url":"https://api.github.com/users/CamDavidsonPilon/received_events","type":"User","site_admin":false},"created_at":"2015-09-21T00:04:52Z","updated_at":"2015-09-21T00:04:52Z","body":"Thanks for the great write up, @bradhackinen. This is pretty serious, so I'll investigate it this week. "}}