Open fredjaya opened 1 week ago
Documented the dependencies for fisher_information.R
functions. Key things to note, and impact whether fi_ funcs should be converted to a method are:
fi_pool(pool_size = 1)
fi_cluster
, don't think these impact the behaviour fi_pool_random
and fi_cluster_random
are good candidates for converting to S3 methods as they are directly used by user-facing functions e.g.# power funcs use only fi_pool_cluster() and fi_pool_cluster_random()
fi(fixed_design) # fi_pool_cluster()
fi(random_design) # fi_pool_cluster_random()
fi_pool
Function | Usage |
---|---|
fi_pool_cluster |
fi_pool(pool_size, prevalence, sensitivity, specificity) |
fi_pool_random |
fi_pool(pooling$pool_size, prevalence, sensitivity, specificity) |
design_effect |
fi_pool(pool_size = 1, prevalence, sensitivity, specificity) |
design_effect_random |
fi_pool(pool_size = 1, prevalence, sensitivity, specificity) |
cost_fi |
fi_pool(pool_size, prevalence, sensitivity, specificity) |
fi_cluster
Function | Usage |
---|---|
design_effect |
fi_pool_cluster(pool_size, pool_number, prevalence, correlation, sensitivity, specificity, form) |
fi_cluster_random |
fi_pool_cluster(pooling$pool_size, pooling$pool_number, prevalence, correlation, sensitivity, specificity, form, real_scale) |
cost_fi_random |
fi_pool_cluster(s, N, prevalence, correlation, sensitivity, specificity, form) |
power_pool |
fi_pool_cluster(pool_size, pool_number, prevalence, correlation, sensitivity, specificity, form) |
sample_size_pool |
fi_pool_cluster(pool_size, pool_number, prevalence, correlation, sensitivity, specificity, form) |
fi_pool_random
Function | Usage |
---|---|
cost_fi_random |
fi_pool_random(catch_dist,pool_strat,prevalence,sensitivity, specificity) |
fi_cluster_random
Function | Usage |
---|---|
design_effect_random |
fi_pool_cluster_random(catch_dist, pool_strat, prevalence, correlation, sensitivity, specificity, form) |
cost_fi_cluster_random |
fi_pool_cluster_random(catch_dist, pool_strat, prevalence, correlation, sensitivity, specificity, form) |
power_pool_random |
fi_pool_cluster_random(catch_dist, pool_strat, prevalence, correlation, sensitivity, specificity, form) |
sample_size_pool_random |
fi_pool_cluster_random(catch_dist, pool_strat, prevalence, correlation, sensitivity, specificity, form) |
classDiagram
fi_pool <-- fi_cluster
fi_pool <-- fi_pool_random
fi_pool <-- design_effect
fi_pool <-- design_effect_random
fi_pool <-- cost_fi
fi_cluster <-- design_effect
fi_cluster <-- fi_cluster_random
fi_cluster <-- cost_fi_random
fi_cluster <-- power
fi_cluster <-- sample_size
fi_pool_random <-- cost_fi_random
fi_cluster_random <-- design_effect_random
fi_cluster_random <-- cost_fi_cluster_random
fi_cluster_random <-- power_random
fi_cluster_random <-- sample_size_random
namespace fisher_information {
class fi_pool {
}
class fi_cluster {
}
class fi_pool_random {
}
class fi_cluster_random {
}
}
namespace cost {
class cost_fi {
}
class cost_fi_random {
}
class cost_fi_cluster_random {
}
}
namespace design {
class design_effect {
}
class design_effect_random {
}
}
namespace power_ns {
class power {
}
class sample_size {
}
class power_random {
}
class sample_size_random {
}
}
Notes from our meeting today:
cluster_number
insample_design
classessample_design
class names to be fixed_design
and variable_design
. Leave PoolTools dropdowns as fixed sample size and fixed sampling period, respectively~~sample_design
params NULL
by default for future optimise()
implementationssample_design
that include e.g. total X
More concrete thoughts after our chat, and how to work on tackling it iteratively. Thoughts and comments please @AngusMcLure!
Goals of refactoring
1. Encapsulating sample design parameters
Current way to run two power functions with shared parameters:
Proposed way is to first store common parameters in an S3 class
sample_design
and pass that to the functionsThe fixed sampling implementation (above) should have the following attributes:
The random/catch sampling implementation attrs:
Also consider the names for each class e.g.
fixed_design
andrandom_design
orcatch_design
, but both will both be of classsample_design
.Cons:
sample_design()
paramssample_design()
every time making the class and functions tightly coupledTo-dos:
2. Add
sample_design
methodsThe use of S3 classes and methods should also improve naming. e.g. each
fixed_design
andrandom_design
. Currently:Proposed, with method dispatch:
The method dispatch will also make the package more extensible for new variations without having really long function names e.g. power e.g. two-sample, one-sample etc.
I think user-facing functions should be given priority for converting functions to sampledesign methods i.e. power/optimise funcs. Non-user facing functions (e.g. fi\, cost_fi...) not so sure yet as it will introduce a lot of dependencies between functions and complicate the code prematurely.
Cons:
Solve with really good/clear documentation and examples, or provide default values for classes.
To-dos:
power_pool
(replace pool with exact thing)3. Refactor power.R functions
Currently all 4
power.R
functions have a lot of duplicated code such as the:To-dos
Hopefully refactoring these will make converting to methods easier.