{"action":"created","issue":{"url":"https://api.github.com/repos/tylermorganwall/skpr/issues/39","repository_url":"https://api.github.com/repos/tylermorganwall/skpr","labels_url":"https://api.github.com/repos/tylermorganwall/skpr/issues/39/labels{/name}","comments_url":"https://api.github.com/repos/tylermorganwall/skpr/issues/39/comments","events_url":"https://api.github.com/repos/tylermorganwall/skpr/issues/39/events","html_url":"https://github.com/tylermorganwall/skpr/issues/39","id":303103451,"number":39,"title":"Evaulating Power Design for Balanced Factors","user":{"login":"Rookie323","id":37147185,"avatar_url":"https://avatars1.githubusercontent.com/u/37147185?v=4","gravatar_id":"","url":"https://api.github.com/users/Rookie323","html_url":"https://github.com/Rookie323","followers_url":"https://api.github.com/users/Rookie323/followers","following_url":"https://api.github.com/users/Rookie323/following{/other_user}","gists_url":"https://api.github.com/users/Rookie323/gists{/gist_id}","starred_url":"https://api.github.com/users/Rookie323/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rookie323/subscriptions","organizations_url":"https://api.github.com/users/Rookie323/orgs","repos_url":"https://api.github.com/users/Rookie323/repos","events_url":"https://api.github.com/users/Rookie323/events{/privacy}","received_events_url":"https://api.github.com/users/Rookie323/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-07T13:44:14Z","updated_at":"2018-03-07T16:30:16Z","closed_at":null,"author_association":"NONE","body":"First I want to say thank you for creating this package.  It was well needed.  \r\n\r\nIf you look at factor \"y\", I need to change the anticoef for conservative power.  Merely adding conservative = TRUE is not sufficient.  \r\n\r\nI have only seen this issue when factors are balanced and parameter power are equal.  \r\n\r\n\r\nExample: \r\nlibrary(AlgDesign)\r\nlibrary(DoE.wrapper)\r\nlibrary(skpr)\r\nlibrary(mefa) # for the rep.data.frame function that replicates a data frame\r\nlibrary(lme4)\r\nlibrary(car)\r\nlibrary(tidyverse)\r\n\r\n\r\n#Creating Design\r\ncand.list <- expand.grid(x=c(1,2,3),y=c(\"Yes\",\"No\"),z= rep(c(\"A\",\"B\",\"C\"),each=2))\r\nrand.cand.list <- cand.list[sample(1:nrow(cand.list)),]\r\ndoe2 <- optFederov(~.^2 + I(x^2), data=rand.cand.list, nTrials=30, nRepeats = 1000)\r\n\r\n#Attempting to calculate conservative power\r\ndoe.eval2 <- eval_design(doe2$design,\r\n                        model=~ (x+y+z)^2 + I(x^2),\r\n                        alpha=.2, effectsize = 1.5,\r\n                        varianceratios = 1, conservative = TRUE,detailedoutput = TRUE\r\n)\r\n\r\ndoe.eval2\r\n\r\n#Changing anticoef to achieve conservative power for effect size of 1.5\r\ndoe.eval2 <- eval_design(doe2$design,\r\n                         model=~ (x+y+z)^2 + I(x^2),\r\n                         alpha=.2, varianceratios = 1, detailedoutput = TRUE,\r\n                         anticoef = c(.75,.75,.75,0,.75,.75,.75,.75,.75,.75,.75)\r\n)\r\n\r\ndoe.eval2\r\n"},"comment":{"url":"https://api.github.com/repos/tylermorganwall/skpr/issues/comments/371196704","html_url":"https://github.com/tylermorganwall/skpr/issues/39#issuecomment-371196704","issue_url":"https://api.github.com/repos/tylermorganwall/skpr/issues/39","id":371196704,"user":{"login":"tylermorganwall","id":297609,"avatar_url":"https://avatars3.githubusercontent.com/u/297609?v=4","gravatar_id":"","url":"https://api.github.com/users/tylermorganwall","html_url":"https://github.com/tylermorganwall","followers_url":"https://api.github.com/users/tylermorganwall/followers","following_url":"https://api.github.com/users/tylermorganwall/following{/other_user}","gists_url":"https://api.github.com/users/tylermorganwall/gists{/gist_id}","starred_url":"https://api.github.com/users/tylermorganwall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tylermorganwall/subscriptions","organizations_url":"https://api.github.com/users/tylermorganwall/orgs","repos_url":"https://api.github.com/users/tylermorganwall/repos","events_url":"https://api.github.com/users/tylermorganwall/events{/privacy}","received_events_url":"https://api.github.com/users/tylermorganwall/received_events","type":"User","site_admin":false},"created_at":"2018-03-07T16:30:16Z","updated_at":"2018-03-07T16:30:16Z","author_association":"OWNER","body":"Glad you find it useful!\r\n\r\nThere is a bug here, although it's slightly different than what you're trying to do. For conservative anticipated coefficients (see [Power Analysis Tutorial for Experimental Design Software](http://www.dtic.mil/get-tr-doc/pdf?AD=ADA619843), page 3-21 to 3-27), all of the anticipated coefficients for a factor are set to zero except for the one with the lowest parameter power, with the one exception of there being a tie. When there is a tie, the anticipated coefficients corresponding to the equal parameter powers are given alternating signs with the same magnitude. Thus, your conservative anticipated coefficients should be:\r\n```r\r\nc(0.75, 0.75, 0.75, 0.75, -0.75, 0.75, 0.75, 0.75, -0.75, 0.75, -0.75)\r\n```\r\nrather than:\r\n```r\r\nc(0.75, 0.75, 0.75, 0.75, 0, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75)\r\n```\r\nThe bug is cancelling out the sign change, and is fixed in the latest version.\r\n\r\nMight I ask, why are you using AlgDesign rather than the built in function gen_design for generating your design? I see you're replicating the candidate set so you can produce a design larger than the size of the unreplicated candidate set--not having to do that is one of the benefits of skpr's gen_design over optFederov.\r\n\r\nHere is the equivalent code for generating the design in skpr itself:\r\n\r\n```r\r\ncand.list <- expand.grid(x=c(1,2,3), y=c(\"Yes\",\"No\"), z= c(\"A\",\"B\",\"C\"))\r\ndoe2 <- gen_design(cand.list, ~(x+y+z)^2 + I(x^2), trials = 30, repeats=1000)\r\n```\r\nor piped:\r\n```r\r\nexpand.grid(x=c(1,2,3), y=c(\"Yes\",\"No\"), z= c(\"A\",\"B\",\"C\")) %>%\r\n  gen_design(~(x+y+z)^2 + I(x^2), trials = 30, repeats=1000) %>%\r\n  eval_design(~(x+y+z)^2 + I(x^2), alpha=0.2, effectsize = 1.5, conservative = TRUE)\r\n```\r\nNote that I removed the varianceratios argument to eval_design, as that argument only changes the output when the input is a split-plot design. There is also no need to randomize the order of the candidate set for gen_design, as it internally does that for you."}}
{"actor":{"display_login":"tylermorganwall"}}