{"action":"created","issue":{"url":"https://api.github.com/repos/Crunch-io/scrunch/issues/332","repository_url":"https://api.github.com/repos/Crunch-io/scrunch","labels_url":"https://api.github.com/repos/Crunch-io/scrunch/issues/332/labels{/name}","comments_url":"https://api.github.com/repos/Crunch-io/scrunch/issues/332/comments","events_url":"https://api.github.com/repos/Crunch-io/scrunch/issues/332/events","html_url":"https://github.com/Crunch-io/scrunch/issues/332","id":385146426,"node_id":"MDU6SXNzdWUzODUxNDY0MjY=","number":332,"title":"derive_weight enhancements","user":{"login":"jamesrkg","id":5341764,"node_id":"MDQ6VXNlcjUzNDE3NjQ=","avatar_url":"https://avatars3.githubusercontent.com/u/5341764?v=4","gravatar_id":"","url":"https://api.github.com/users/jamesrkg","html_url":"https://github.com/jamesrkg","followers_url":"https://api.github.com/users/jamesrkg/followers","following_url":"https://api.github.com/users/jamesrkg/following{/other_user}","gists_url":"https://api.github.com/users/jamesrkg/gists{/gist_id}","starred_url":"https://api.github.com/users/jamesrkg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamesrkg/subscriptions","organizations_url":"https://api.github.com/users/jamesrkg/orgs","repos_url":"https://api.github.com/users/jamesrkg/repos","events_url":"https://api.github.com/users/jamesrkg/events{/privacy}","received_events_url":"https://api.github.com/users/jamesrkg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"xbito","id":205580,"node_id":"MDQ6VXNlcjIwNTU4MA==","avatar_url":"https://avatars0.githubusercontent.com/u/205580?v=4","gravatar_id":"","url":"https://api.github.com/users/xbito","html_url":"https://github.com/xbito","followers_url":"https://api.github.com/users/xbito/followers","following_url":"https://api.github.com/users/xbito/following{/other_user}","gists_url":"https://api.github.com/users/xbito/gists{/gist_id}","starred_url":"https://api.github.com/users/xbito/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xbito/subscriptions","organizations_url":"https://api.github.com/users/xbito/orgs","repos_url":"https://api.github.com/users/xbito/repos","events_url":"https://api.github.com/users/xbito/events{/privacy}","received_events_url":"https://api.github.com/users/xbito/received_events","type":"User","site_admin":false},"assignees":[{"login":"xbito","id":205580,"node_id":"MDQ6VXNlcjIwNTU4MA==","avatar_url":"https://avatars0.githubusercontent.com/u/205580?v=4","gravatar_id":"","url":"https://api.github.com/users/xbito","html_url":"https://github.com/xbito","followers_url":"https://api.github.com/users/xbito/followers","following_url":"https://api.github.com/users/xbito/following{/other_user}","gists_url":"https://api.github.com/users/xbito/gists{/gist_id}","starred_url":"https://api.github.com/users/xbito/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xbito/subscriptions","organizations_url":"https://api.github.com/users/xbito/orgs","repos_url":"https://api.github.com/users/xbito/repos","events_url":"https://api.github.com/users/xbito/events{/privacy}","received_events_url":"https://api.github.com/users/xbito/received_events","type":"User","site_admin":false},{"login":"mathiasbc","id":1334386,"node_id":"MDQ6VXNlcjEzMzQzODY=","avatar_url":"https://avatars3.githubusercontent.com/u/1334386?v=4","gravatar_id":"","url":"https://api.github.com/users/mathiasbc","html_url":"https://github.com/mathiasbc","followers_url":"https://api.github.com/users/mathiasbc/followers","following_url":"https://api.github.com/users/mathiasbc/following{/other_user}","gists_url":"https://api.github.com/users/mathiasbc/gists{/gist_id}","starred_url":"https://api.github.com/users/mathiasbc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mathiasbc/subscriptions","organizations_url":"https://api.github.com/users/mathiasbc/orgs","repos_url":"https://api.github.com/users/mathiasbc/repos","events_url":"https://api.github.com/users/mathiasbc/events{/privacy}","received_events_url":"https://api.github.com/users/mathiasbc/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2018-11-28T08:06:01Z","updated_at":"2018-12-12T22:14:48Z","closed_at":null,"author_association":"COLLABORATOR","body":"Now that we have `derive_weight` (#324) we need to look at some enhancements for the initial implementation. \r\n\r\nIt's not clear to me how much of this is implemented on the Crunch side. @jjdelc we'll need your input to clarify what is/isn't currently possible (hence initial assignment of this ticket). I'm not sure if any of it is currently supported. If that is the case we'll have to leave this in the back log and I will email support instead.\r\n\r\nI've take these enhancements from the original ticket (#57).\r\n\r\n1. Multiple source weight lists/variables via a list of dict given to `targets`:\r\n\r\n```\r\nds.derive_weight(\r\n    targets=[\r\n        {'gender' : {\r\n            1: .45, \r\n            2: .55}},\r\n        {'locality': {\r\n            1: .10, \r\n            2: .15, \r\n            3: .20, \r\n            4: .25, \r\n            5: .30}}\r\n    ],\r\n    alias='age-weight-test',\r\n    name='age-weight-test'\r\n)\r\n```\r\n\r\n2. Applying weights only to a subgroup via `filter`\r\n\r\n```\r\nds.derive_weight(\r\n    filter='wave == 1',\r\n    targets=[\r\n        {'gender' : {\r\n            1: .45, \r\n            2: .55}},\r\n        {'locality': {\r\n            1: .10, \r\n            2: .15, \r\n            3: .20, \r\n            4: .25, \r\n            5: .30}}\r\n    ],\r\n    alias='age-weight-test',\r\n    name='age-weight-test'\r\n)\r\n```\r\n\r\n3. Control the total weighted base via 'total' (rename as preferred!):\r\n\r\n```\r\nds.derive_weight(\r\n    total=10000,\r\n    targets=[\r\n        {'gender' : {\r\n            1: .45, \r\n            2: .55}},\r\n        {'locality': {\r\n            1: .10, \r\n            2: .15, \r\n            3: .20, \r\n            4: .25, \r\n            5: .30}}\r\n    ],\r\n    alias='age-weight-test',\r\n    name='age-weight-test'\r\n)\r\n```\r\n\r\nIn this example the total weighted base would appear to be 10,000."},"comment":{"url":"https://api.github.com/repos/Crunch-io/scrunch/issues/comments/446764605","html_url":"https://github.com/Crunch-io/scrunch/issues/332#issuecomment-446764605","issue_url":"https://api.github.com/repos/Crunch-io/scrunch/issues/332","id":446764605,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0Njc2NDYwNQ==","user":{"login":"mathiasbc","id":1334386,"node_id":"MDQ6VXNlcjEzMzQzODY=","avatar_url":"https://avatars3.githubusercontent.com/u/1334386?v=4","gravatar_id":"","url":"https://api.github.com/users/mathiasbc","html_url":"https://github.com/mathiasbc","followers_url":"https://api.github.com/users/mathiasbc/followers","following_url":"https://api.github.com/users/mathiasbc/following{/other_user}","gists_url":"https://api.github.com/users/mathiasbc/gists{/gist_id}","starred_url":"https://api.github.com/users/mathiasbc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mathiasbc/subscriptions","organizations_url":"https://api.github.com/users/mathiasbc/orgs","repos_url":"https://api.github.com/users/mathiasbc/repos","events_url":"https://api.github.com/users/mathiasbc/events{/privacy}","received_events_url":"https://api.github.com/users/mathiasbc/received_events","type":"User","site_admin":false},"created_at":"2018-12-12T22:14:48Z","updated_at":"2018-12-12T22:14:48Z","author_association":"COLLABORATOR","body":"https://github.com/Crunch-io/scrunch/pull/336"}}
{"actor":{"display_login":"mathiasbc"}}