kenkleinman / clusterpower Goto Github PK
View Code? Open in Web Editor NEWthe clusterPower package for R: simulating power and sample size calculations for cluster-randomized trials
the clusterPower package for R: simulating power and sample size calculations for cluster-randomized trials
If n.periods=1 is specified, than throw warning if period.effect or period.var is specified.
Warning: Error in data.frame: arguments imply differing number of rows: 216, 233
74: stop
73: data.frame
72: observeEventHandler [C:\Users\acbro0\Documents\Kleinman-computer\clusterPower\inst\shiny-examples\app/app.R#2325]
1: runApp
triggered on the next run after nearPoints is activated.
In cps.ma.internal...
I had told ken and lexi earlier that the code for the 'varying sigma2_b and varying sigma' should be this, and it was implemented:
my.mod <- nlme::lme(y~as.factor(trt2), random=~1+as.factor(trt2)|clust2, weights=nlme::varIdent(form=~1|as.factor(trt2)), method="ML", control=nlme::lmeControl(opt='optim'))
BUT to converge more consistently, set the optimizer to Nelder-Mead. Should look something like:
my.mod <- nlme::lme(y~as.factor(trt2), random=~1+as.factor(trt2)|clust2, weights=nlme::varIdent(form=~1|as.factor(trt2)), method="ML", control = lmeControl(opt = "optim", optimMethod = "Nelder-Mead"))
When running a power.sim.normal, we get this warning:
1: In glmer(y ~ trt + (1 | clust), data = dat, family = outcome.type, :
calling glmer() with family=gaussian (identity link) as a shortcut to lmer() is deprecated; please call lmer() directly
When running the code using !is.integer()
to ensure nsim, n, m, and difference are all whole numbers, function will properly run for first function call, but any subsequent calls of cps.normal
will classify nsim, n, m, and difference as class: double and will result in error message. While not an issue in and of itself, after this point neither !is.integer()
OR 'is.integer()` work; both come back FALSE.
I suspect this may be an issue specific to my machine.
The helper function is.wholenumber
is created to address this issue, however using is.integer()
would be preferred.
Appears to enforce infinite degrees of freedom at all times? Per Josh, 6/18/19
Error in round: non-numeric argument to mathematical function
from is.wholenumber fxn
which argument is causing this?
The system of "n" and "m" is not working.
I suggest that all the functions use "nc" for number of clusters and "ns" for number of subjects throughout the package. Other proposals welcome.
I recognize that this is a PIA, but I think it will pay off for users and ourselves.
Change sigma_b to sigma_b_sq in Alex’s code
In cps.sw.count(), c.ntrt and c.trt say that they accept a scalar between 0-1, but that’s not what’s in the example (c.ntrt=3, c.trt=5),
For SW designs put in roxygen comments that we need to make explicit language to describe stepped wedge design. Clarify steps.
Give user access to glmcontrol in the … (but include in arguments) (can ask Josh for advice on optimizers)
Testthat test in 4c won’t run, but components run fine - try a different optimizer - still working on this
Suppress warnings
Fix progress bar/cluster computing issue (normal method has faulty time estimation)
For multi-arm simulation methods
Change output to have binary match normal, seed
Avg betas in default print method
Pairwise comparisons in output
Continue testthat tests
Check params/return objects in documentation
Include table1 as summary method -- recreate Alex’s/Jon’s print/summary methods, avg number of subjects in each arm, clusters in each arm
Option to include ICC output
Check means, residual error, cluster means are what they’re supposed to be.
Observed ICC for multi-arm trial- use Alex’s lmer_icc method (ANOVA?)
Add to man page:
Examples used in testing compared to NIH
Example using different methods
Testing:
Test across a range of powers for simulations
Change simulation number to 1000
(p1.base, p2.base, p1.followup, p2.followup, get rid of odds ratios for did.binary (revisit before I do this)
Have all the simulated methods stop if power is <0.5, by default
Checkout did.binary more closely bc it doesn’t seem to match NIH and PASS
Must be able to set the seed on all simulation methods.
Ask Josh about Laplace vs. numerical quadrature for simulated methods.
Cps.binary option for parallel computing?
Cps.binary (and others?) arguments appear in CAPS in the error messages but the actual arguments are in lower case.- Ken says this can be changed, helpful error messages.
Vignette
Equation for stepped wedge designs, more explanation
More explanation: multi-arm trial designs
Compare to CRTsize pkg, Pass11 in the vignette
IRGTTs where all subjects are treated in groups should be treated as CRTs for the purposes of power calculation, though most likely we need separate sigma/ICC per tx group. This should be noted in the man pages for the IRGTT functions and/or in a vignette for IRGTTs.
I removed this option for now, I can put it back in later. Need to restore "method" to the arguments and the if/then statement that provides GEE as an alternative to glmm.
in cps.normal line 250-285 vs. 290- 335; IRGTT uses 0. as.factor, other does not. Is there an effect of this?????
But if you build a source package and then install from the source package, the vignette installs properly. (?!)
And the effect of all those singular fits that happen when it is used.
nclusters and nsubjects are not arguments for irgtt. Or else if they are, there should be a note as to what they mean in the irgtt context.
** libs
llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC -mtune=core2 -g -O2 -c RcppExports.cpp -o RcppExports.o
RcppExports.cpp:4:18: error: Rcpp.h: No such file or directory
RcppExports.cpp:6: error: ‘Rcpp’ is not a namespace-name
RcppExports.cpp:6: error: expected namespace-name before ‘;’ token
RcppExports.cpp:9: error: ‘List’ does not name a type
RcppExports.cpp:10: error: ‘RcppExport’ does not name a type
make: *** [RcppExports.o] Error 1
ERROR: compilation failed for package ‘clusterPower’
Exited with status 1.
Unhandled promise error: nclusters/steps must be a whole number. See documentation for steps parameter in '?clusterPower::cps.sw.binary'
Unhandled promise error: unused arguments (power = q$power, ntimes = q$ntimescpaswnormal, d = q$dcpaswnormal, ICC = q$ICCcpaswnormal, rho_c = q$rho_ccpaswnormal, rho_s = q$rho_scpaswnormal, vart = q$vartcpaswnormal)
Exactly one of 'alpha', 'power', 'nclusters', 'nsubjects', 'CV', 'p1', 'p2', or 'ICC' must be NA.
Because not all packages are there.
All mismatched quotes and/or braces
Right now it only updates after a successful run, which is confusing and not as helpful.
This is not a issue in the code; just something to be considered.
Presently, at least 2 variance parameters must be specified for Group 1 for cps.normal
to run. If only 1 variance parameter for Group 2 is specified, the code currently throws an error, informing the user they must specify at least 2 variance parameters if they wish to specify them for Group 2. If no variance parameters are specified for Group 2, they are assumed equal to those of Group 1.
The proposed issue would have Group 2 inherit a variance parameter from Group 1 to cover the deficit, under the assumption that the inherited parameter is equal between Groups. It has not been discussed which parameter would be inherited from Group 1 if both are missing from Group 2 (e.g. ICC & sigma have been specified for Group 1, and sigma_b has been specified for Group 2).
may be a non-issue on a higher powered computer
b <- power.sim.binomial(n.sim=10, effect.size=log(.75), alpha=.05, n.clusters=20, n.periods=2,
cluster.size=50, btw.clust.var=.2, period.effect=logit(.2),
estimation.function=random.effect, verbose=TRUE, period.var=0)
gives the error
starting simulation :: 2015-05-19 22:06:08
Error in diag(vcov(object, use.hessian = use.hessian)) :
error in evaluating the argument 'x' in selecting a method for function 'diag': Error in calc.vcov.hess(h) : could not find function "forceSymmetric"
Same with
c <- power.sim.poisson(n.sim=10, effect.size=log(.75), alpha=.05, n.clusters=100, n.periods=2,
cluster.size=10, btw.clust.var=.4, period.effect=log(.2),
estimation.function=random.effect, verbose=TRUE, period.var=0, at.risk.params=10)
These lines will be truncated in the PDF manual.
Please fix, and re-check with R-patched or R-devel.
Warning in glmer(y ~ trt + (1 | clust), data = dat, family = outcome.type, :
calling glmer() with family=gaussian (identity link) as a shortcut to lmer() is deprecated; please call lmer() directly
Need an update to remove a letter from a function?
Warning: Error in <-: 'names' attribute [8] must be the same length as the vector [3]
65: updateArgs [C:\Users\acbro0\Documents\Kleinman-computer\clusterPower\inst\shiny-examples\app/app.R#1333]
61: reactive:args [C:\Users\acbro0\Documents\Kleinman-computer\clusterPower\inst\shiny-examples\app/app.R#2006]
syntax:
\deqn{latex equation}{ascii equation}
This will be a PIA, but not too hard
Once calculation has begun, it cannot be cancelled. Solution requires implementation of futures pkg, which I am researching and testing.
Otherwise the table is kinda confusing
Again, this can likely be addressed with futures, which I currently only understand enough to be dangerous. But not for long.
Actively troubleshooting this issue. When examining output, entries in pval.vector
appear to be double entered (e.g. 0.432, 0.432, 0.005, 0.005, 0.018, 0.018, ...). This results artificially tighter confidence intervals as nsim
increases, since SE = sqrt(p * (1 - p) / nsim) vs. SE = sqrt(p * (1 - p) / (nsim*2))
Note: Code must be modified for pval.vector
to be output. This is not natively supported.
is rather more than the 'few seconds' of the CRAN policies and should be reduced.
See cps.sw.normal.R for example of how to start. Could also remove append() calls.
When using cps.sw
functions, if a user specifies all.sim.data == TRUE
, the resulting output objects can quickly become prohibitively large (>500MB), especially on computers with low RAM. I attempted to resolve this issue by storing the simulated data sets as matrices instead of data frames. However the resulting list of matrices supplied to the user was still comparable in size to the list of data frames.
I think it may be beneficial to explicitly warn users in the Roxygen comments for all.sim.data
in the event no viable solution is found. An alternative might be storing only the response values y
and creating an ancillary function that can take as an input that vector as well as nsubjects
, nclusters
& steps
to reconstruct the data.frames
cps.normal(), at least, generates an irritating number of estimates. I would guess that it need not generate more than one message every 10 seconds. Here is what I would propose:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.