{"action":"created","issue":{"url":"https://api.github.com/repos/DeclareDesign/estimatr/issues/259","repository_url":"https://api.github.com/repos/DeclareDesign/estimatr","labels_url":"https://api.github.com/repos/DeclareDesign/estimatr/issues/259/labels{/name}","comments_url":"https://api.github.com/repos/DeclareDesign/estimatr/issues/259/comments","events_url":"https://api.github.com/repos/DeclareDesign/estimatr/issues/259/events","html_url":"https://github.com/DeclareDesign/estimatr/issues/259","id":360558373,"node_id":"MDU6SXNzdWUzNjA1NTgzNzM=","number":259,"title":"Bug for difference in means with clusters and specified conditions?","user":{"login":"macartan","id":12734205,"node_id":"MDQ6VXNlcjEyNzM0MjA1","avatar_url":"https://avatars1.githubusercontent.com/u/12734205?v=4","gravatar_id":"","url":"https://api.github.com/users/macartan","html_url":"https://github.com/macartan","followers_url":"https://api.github.com/users/macartan/followers","following_url":"https://api.github.com/users/macartan/following{/other_user}","gists_url":"https://api.github.com/users/macartan/gists{/gist_id}","starred_url":"https://api.github.com/users/macartan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/macartan/subscriptions","organizations_url":"https://api.github.com/users/macartan/orgs","repos_url":"https://api.github.com/users/macartan/repos","events_url":"https://api.github.com/users/macartan/events{/privacy}","received_events_url":"https://api.github.com/users/macartan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-09-15T17:15:23Z","updated_at":"2018-09-15T17:52:26Z","closed_at":null,"author_association":"NONE","body":"First answer below (where clusters included) looks clearly wrong:\r\n\r\n```\r\ndf <- fabricate(clusters = add_level(N = 12, Z = rep(0:2,4)),\r\n                i = add_level(N = 3, Y = Z + .001*rnorm(N)))\r\n\r\n\r\n> difference_in_means(formula = Y ~ Z, data = df,  clusters = clusters, condition1 = \"0\", condition2 = \"1\")\r\nDesign:  Clustered \r\n       Estimate Std. Error       t value Pr(>|t|)   CI Lower  CI Upper       DF\r\nZ -0.0002082096  0.3778762 -0.0005509996 0.999578 -0.9212919 0.9208755 6.096774\r\n\r\ndifference_in_means(formula = Y ~ Z, data = df, condition1 = \"0\", condition2 = \"1\")\r\n\r\nDesign:  Standard \r\n   Estimate   Std. Error  t value     Pr(>|t|)  CI Lower CI Upper       DF\r\nZ 0.9995582 0.0003962792 2522.358 3.640399e-59 0.9987342 1.000382 21.04731\r\n```\r\n\r\nIn contrast no issues here; suggesting that his is related to data subsetting when there are clusters:\r\n\r\n```\r\n> df2 <- fabricate(clusters = add_level(N = 12, Z = rep(0:1,6)),\r\n+                 i = add_level(N = 3, Y = Z + .001*rnorm(N)))\r\n\r\n> difference_in_means(formula = Y ~ Z, data = df2, \r\n+                     clusters = clusters, condition1 = \"0\", condition2 = \"1\")\r\nDesign:  Clustered \r\n   Estimate  Std. Error t value     Pr(>|t|)  CI Lower CI Upper DF\r\nZ 0.9996711 0.000339741 2942.45 5.058327e-31 0.9989141 1.000428 10\r\n\r\n> difference_in_means(formula = Y ~ Z, data = df2, \r\n+                     condition1 = \"0\", condition2 = \"1\")\r\nDesign:  Standard \r\n   Estimate  Std. Error  t value    Pr(>|t|)  CI Lower CI Upper       DF\r\nZ 0.9996711 0.000279948 3570.917 4.79528e-95 0.9991018  1.00024 33.49292\r\n\r\n> difference_in_means(formula = Y ~ Z, data = df2, clusters = clusters)\r\nDesign:  Clustered \r\n   Estimate  Std. Error t value     Pr(>|t|)  CI Lower CI Upper DF\r\nZ 0.9996711 0.000339741 2942.45 5.058327e-31 0.9989141 1.000428 10\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/DeclareDesign/estimatr/issues/comments/421607183","html_url":"https://github.com/DeclareDesign/estimatr/issues/259#issuecomment-421607183","issue_url":"https://api.github.com/repos/DeclareDesign/estimatr/issues/259","id":421607183,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMTYwNzE4Mw==","user":{"login":"lukesonnet","id":5298599,"node_id":"MDQ6VXNlcjUyOTg1OTk=","avatar_url":"https://avatars0.githubusercontent.com/u/5298599?v=4","gravatar_id":"","url":"https://api.github.com/users/lukesonnet","html_url":"https://github.com/lukesonnet","followers_url":"https://api.github.com/users/lukesonnet/followers","following_url":"https://api.github.com/users/lukesonnet/following{/other_user}","gists_url":"https://api.github.com/users/lukesonnet/gists{/gist_id}","starred_url":"https://api.github.com/users/lukesonnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukesonnet/subscriptions","organizations_url":"https://api.github.com/users/lukesonnet/orgs","repos_url":"https://api.github.com/users/lukesonnet/repos","events_url":"https://api.github.com/users/lukesonnet/events{/privacy}","received_events_url":"https://api.github.com/users/lukesonnet/received_events","type":"User","site_admin":false},"created_at":"2018-09-15T17:52:26Z","updated_at":"2018-09-15T17:52:26Z","author_association":"MEMBER","body":"Bad bugs like this are not something I want to have in the world. Thanks for digging it up."}}
{"actor":{"display_login":"lukesonnet"}}