{"action":"created","issue":{"url":"https://api.github.com/repos/tidyverse/broom/issues/173","repository_url":"https://api.github.com/repos/tidyverse/broom","labels_url":"https://api.github.com/repos/tidyverse/broom/issues/173/labels{/name}","comments_url":"https://api.github.com/repos/tidyverse/broom/issues/173/comments","events_url":"https://api.github.com/repos/tidyverse/broom/issues/173/events","html_url":"https://github.com/tidyverse/broom/issues/173","id":189910619,"number":173,"title":"tidy segmented model","user":{"login":"dschneiderch","id":7461221,"avatar_url":"https://avatars.githubusercontent.com/u/7461221?v=3","gravatar_id":"","url":"https://api.github.com/users/dschneiderch","html_url":"https://github.com/dschneiderch","followers_url":"https://api.github.com/users/dschneiderch/followers","following_url":"https://api.github.com/users/dschneiderch/following{/other_user}","gists_url":"https://api.github.com/users/dschneiderch/gists{/gist_id}","starred_url":"https://api.github.com/users/dschneiderch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dschneiderch/subscriptions","organizations_url":"https://api.github.com/users/dschneiderch/orgs","repos_url":"https://api.github.com/users/dschneiderch/repos","events_url":"https://api.github.com/users/dschneiderch/events{/privacy}","received_events_url":"https://api.github.com/users/dschneiderch/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-17T01:51:21Z","updated_at":"2016-11-17T02:18:58Z","closed_at":null,"body":"tidy() for a segmented object always returns 0 for the estimate and 1 for p value, as far as I can tell. Interestingly, std.error is not 0.\r\nshouldn't the estimate be the breakpoint and the pvalue from davies.test() of the linear (non-segmented model)?\r\nOne thing I'm unsure about is which breakpoint to report, that from segmented() or that from davies.test(). They report slightly different breakpoint estimates. \r\n\r\ndavies.test() requires the original linear model rather than the segmented model, is why estimate and pvalue are 0 from tidy()? in this case, NA would be better I think.\r\n\r\n```\r\nlibrary(segmented)\r\nlibrary(broom)\r\nlinmdl=lm(snw~sca,data=robdata)\r\nss=segmented(linmdl,~sca,psi=.1)\r\ndavies.test(linmdl,~sca)\r\ntidy(ss)\r\n```\r\n\r\nsome example data:\r\n```\r\nstructure(list(snw = c(1.3379867094972, 0.732666495037936, 0.576903227087757, \r\n0.144938045383969, 0.0628010823651208, 0.00453322001892654, 1.15372637435442, \r\n1.38712582663615, 1.17866505632708, 0.982191140775396, 0.956481184860154, \r\n0.783034855873891, 0.554488835472683, 0.304550401827063, 0.177324502497286, \r\n0.0898379755490509, 0.281017699834271, 0.381077539188414, 0.25228770558561, \r\n0.122760780431337, 0.581122881761823, 0.212218758067146, 0.334626086593144, \r\n0.0858645853494403, 0.0327680112921047, 0.000676543292026933, \r\n1.0527051537889, 0.62614124724974, 0.360061995530027, 0.196180357035871, \r\n0.0596823902053918, 0.0109758173684739, 0.00177871950733928), \r\n    sca = c(0.854385917448981, 0.760400039679319, 0.671509347185023, \r\n    0.244613983352722, 0.145578010442875, 0.0228516805093382, \r\n    0.897329762194627, 0.957173389605822, 0.927648369089811, \r\n    0.836818800782765, 0.909098287476666, 0.799042285528772, \r\n    0.681429176924672, 0.454192931670409, 0.308876444011579, \r\n    0.193644094544995, 0.524867209551894, 0.65655745835926, 0.475971466962458, \r\n    0.290705119533948, 0.92523153784415, 0.428554680806933, 0.845485124764404, \r\n    0.18902686470254, 0.0907934961989016, 0.0033817601385169, \r\n    0.781006231456682, 0.696660624588552, 0.496902307713118, \r\n    0.333766198631063, 0.142746349953557, 0.0257013770527284, \r\n    0.00419338257176095)), .Names = c(\"snw\", \"sca\"), row.names = c(NA, \r\n-33L), class = \"data.frame\")\r\n```"},"comment":{"url":"https://api.github.com/repos/tidyverse/broom/issues/comments/261135572","html_url":"https://github.com/tidyverse/broom/issues/173#issuecomment-261135572","issue_url":"https://api.github.com/repos/tidyverse/broom/issues/173","id":261135572,"user":{"login":"dgrtwo","id":994718,"avatar_url":"https://avatars.githubusercontent.com/u/994718?v=3","gravatar_id":"","url":"https://api.github.com/users/dgrtwo","html_url":"https://github.com/dgrtwo","followers_url":"https://api.github.com/users/dgrtwo/followers","following_url":"https://api.github.com/users/dgrtwo/following{/other_user}","gists_url":"https://api.github.com/users/dgrtwo/gists{/gist_id}","starred_url":"https://api.github.com/users/dgrtwo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgrtwo/subscriptions","organizations_url":"https://api.github.com/users/dgrtwo/orgs","repos_url":"https://api.github.com/users/dgrtwo/repos","events_url":"https://api.github.com/users/dgrtwo/events{/privacy}","received_events_url":"https://api.github.com/users/dgrtwo/received_events","type":"User","site_admin":false},"created_at":"2016-11-17T02:18:58Z","updated_at":"2016-11-17T02:18:58Z","body":"Interesting question. There is no method specific to `segmented` objects- instead, what is being called is `tidy.lm` (since segmented objects are also `lm` objects). Thus, it is just a tidied version of:\r\n\r\n    summary(ss)$coefficients\r\n\r\nFrom a bit of examination it looks like you should not pay any attention to the psi estimate or p-value in here, only to the `davies.test` one.\r\n\r\nI'll try to return to this at some point to get `segmented` objects a better tidying method!"}}
{"actor":{"display_login":"dgrtwo"}}