Closed jwasserman2 closed 5 months ago
Per discussion with Josh:
WeightedDesign
with numeric
, checking of equality of Design
is disabled"is_dichotomized
and is_binary_or_dichotomized` functionstreatment
, remove binary=
argument (equivalent to testing whether dichotomy=
argument is NULL
).bin_txt
- At least one of these must be true: a) the treatment is binary, or b) the dichotomy=
argument must be non-NULL
. .get_dichotomy
to something like .handle_dichotomy
or .process_dichotomy
I'd like to request a small addition to the nice chunk of work that was recently added on this branch. Looking over the discussion and the tests, it's not immediately clear to me where we landed with regard to use of the CombinedWeightedDesign class. File test.CWD.R now has a number of instances of expect_false(inherits(foo, "CombinedWeightedDesign"))
, but no corresponding expect_true()
's (nor any expect_s4_class(foo, "CombinedWeightedDesign")
's). This suggests that we landed on not using it. But the title of the file suggests that it's a thing, as do the inline comments surrounding the class definition and various of my inline notes in test.CWD.R -- e.g. comments in this block.
Could someone just update the inline notes to clarify? Particularly in test.CWD.R, and maybe CWD.R. I imagine this could be either Josh W or Josh E. Please don't hesitate to trash inline notes of mine that no longer apply. If it's appropriate to remove the CWD definition, I'm OK with that too; whatever leaves us a clearer trail of crumbs when we find ourselves maintaining this in the future.
I think it'd be clearest if we just delete the CombinedWeightedDesign
class from CombinedWeightedDesign.R
and any tests in test.CombinedWeightedDesign.R
that reference it, so if people find that acceptable I can go ahead and do that
I agree, let's remove all traces of CombinedWeightedDesign
if we're not going to use it.
Makes sense to me. If indeed we'll remove all traces of CWD, I'd suggest indicating that clearly in the commit message, in the event that we should someday think of another use for some of that nice code.
Where JW says get rid of tests referencing CWD, I take him to mean get rid of the parts of those tests that reference CWD. The tests of combining WDs are probably worth keeping around.
If there'll no longer be a CWD class, perhaps the names of these files should be changed accordingly too: e.g. CombinedWeightedDesign.R
-> combine_WeightedDesign.R
, test.CombinedWeightedDesign.R
-> test.combine_WeightedDesign.R
.
Commit eedc0c4 addresses the final string of comments
Major changes (in order of the files changed below)
c()
forWeightedDesign
objectsDesign
slotwarn_dichotomy_not_equal
isTRUE
(default isFALSE
) and objects have the sameDesign
slot but differingdichotomy
slotsDesign
ortarget
slots or if not all objects areWeightedDesign
WeightedDesign
is concatenated with anumeric
? A: instead of an error, we should provide a message saying we're not checking whetherDesign
ortarget
are the sameDesign
objectsdichotomy
slotsdichotomy
extractor functionis_dichotomized
identical_designs
treatment()
/.bin_txt()
.bin_txt()
now accepts optionaldata
anddichotomy
arguments in addition toDesign
.bin_txt()
logic:Design
usingtreatment(Design, binary = FALSE)
data
is notNULL
, join treatment todata
on unit of assignment information using.expand_txt()
(existing code fromassigned()
that I made into a helper function). Ifdichotomy
refers to a non-treatment variable, it must be provided indata
by
argument?dichotomy
is notNULL
, dichotomize the treatment using.apply_dichotomy()
treatment()
now acceptsdichotomy
argumenttreatment()
logic:binary == FALSE
, return.get_col_from_new_data
ifnewdata
is notNULL
or treatment column fromDesign
if it isbinary == TRUE
anddichotomy
is notNULL
, return.bin_txt()
binary == TRUE
anddichotomy
isNULL
andhas_binary_treatment(Design)
isFALSE
, error. Otherwise perform same logic asbinary == FALSE
WeightedDesign
objectsdichotomy
slotassigned()
dichotomy
arugmentdichotomy
is provided, returns treatment stored in theDesign
if nodata
is provided, otherwise returns treatment joined todata
data
isNULL
and.get_data_from_model
doesn't find non-treatment variables in thedichotomy
.get_dichotomy()
dichotomy
argument provided inlmitt
, aWeightedDesign
, or a call provided to theweights
argument inlmitt
. If.get_dichotomy()
was provided a dichotomy itself, it compares that dichotomy against any found further up the stacklmitt()
dichotomy
argumentdichotomy
provided in the call or object provided toweights
argumentdichotomy
is provideddichotomy
argument toassigned()
in the generated formula, but remove it from the column names of the model matrix.weights_calc()
data
argument even necessary in the.bin_txt()
call?