Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated package functions #25

Merged
merged 67 commits into from
Feb 7, 2024
Merged

Updated package functions #25

merged 67 commits into from
Feb 7, 2024

Conversation

kjakobse
Copy link
Collaborator

@kjakobse kjakobse commented Feb 1, 2024

  • Added adls function try_catch_warnings().
  • Updated adls functions braid_rows() and flatten_date_intervals().
  • Added aso function freq_function(), freq_function_repeated(), odds_ratio_function(), odds_ratio_function_repeated(), and many_merge().
  • Updated aso function charlson_score().
  • Added kija function CovariateBalance() for generalized random forest analysis.
  • Updated kija functions CForBenefit(), CATESurface(), CausalForestDynamicSubgroups(), DiscreteCovariatesToOneHot(), RATEOmnibusTest(), and RATETest() for generalized random forest analysis.
  • Updated kija functions fct_confint(), lms(), and multi_join().

Laksafoss and others added 30 commits June 13, 2023 13:09
aso_odds_ratio_function
aso_odds_ratio_funciton_repeated
When using data masking and tidy selection no global variable with that name is avalible - it only exisits in the context of the current data frame. Therefore, the CRAN check will complain that there is "no global variable definition for" the variable.

In a tidy select context we just use the quoted column name. In a data masking context we must explicitly refere to the current context data fram by writing `.data$variable` when using `variable`.
Note that it was necissary to make a summary method for `svy_vglm` objects, as the summary method for these is not exported from the svyVGAM package.
Add CovariateBalance function
Updated braid_rows function.
Updated causal forest examples to run faster.
General improvements.
- Option to output eCDF plots
- Option to output a table of balance statistics

Fixed in RateTest:
- Correctly pass formals to grf::rank_average_treatment_effect
… observed outcome for treated minus observed outcome for non-treated.
Use convex optimization to find confidence set of functions of model parameters unless problem is not convex or user specifies otherwise. This solver is expected to be much faster than the previous solver, where a grid of points was projected to the boundary, and is also more accurate, as we are guarantied to get the correct boudaries.

Add cli, snow, and doSNOW to suggests.

Add improved checks of input to fct_confint.
Added check if package cli is installed when required and asks to install.

Improved handling of required data for different choices of matching method and tau_hat_method.

Move to complete dplyr data flow.

Add a formatted tibble with c-for-benefit results to output.
multi_join implements the functionality in many_merge with additional name and error handling.
- Add check for by_vars
- Update check for include_NA to check for boolean instead of logical.
- Add check for weightvar
- match output to list of possible arguments.
Remove instances were a character is first quoted then deparsed back to a character.

Remove substitute from freq_function were symbol func_var is not substituted. Move rename to account for this.

Remove unnecessary paste + gsub from deparse substitute pattern in charlson_score. Add check to ensure Person_ID is length 1.
When model_object=TRUE the function returns the output of the modelling function that was used without standardising the output. Early returns are used so unnecessary standardisation is not performed before returning.
Update some names of intermediate tables to make them consistent regardless if using `svyglm` or `svy_vglm`.
Update `odds_ratio_functions' to remove .data pronouns used in situations where a symbol is supposed to refer to an environment object and not a column in the data mask.
Pipe data into add_row to improve readability.
-Place spaces before left parentheses.
-Place spaces before curly brackets.
-No new line for else in control flow.
- Use long form logical operators in control flow.
- Check spelling.
- Check indentation.
- Use `ifelse` instead of `dplyr::case_when` when there is only one condition.
- Combine records using dplyr::across instead of copy-pasting the same function across all health conditions.
- Remove lines where columns in func_table are multiplied with 1 (when assigning points for the Charlson specification).
- Add warning about non-positive weights in weightvar.
- Check use of embrace.
- Check tidyselect syntax (primarily using `dplyr::all_of` instead of embrace).
- Check data mask syntax.
- Use name injection instead of renaming var1 and var2 columns at the start and restoring names at the end.
- Move away from saving separate intermediate objects (func_tablex).  Instead keep intermediate steps assigned to func_table. Only keep an intermediate object which are important for other calculations (such as chi-square statistics). Otherwise use pipes to keep track of steps.
- Move chi-square calculations to their logical locations in the stream of operations.
- Remove conditions in control flow where no changes are made.
- Use requireNamespace to check if suggested package is installed.
- Fix punctuation in error messages.
- Add missing .data pronouns.
- Add missing embrace.
- Remove unecessary control flow when selecting covariates based on the existence of colnames for cf$.orig (both cases are covered by dplyr::all_of.
- Add missing embrace operators.
- Add missing .data pronouns.
- Quote names used in selection.
- Check if suggested packages are installed using requireNamespace.
- Add foreach, parallel, doParallel, and CVXR to suggested packages.
- Ask user for permission to install a required package if not already installed.
- Carry all needed objects into ci_fct and ci_fct_error_handler.
- Update order of formal arguments in fct_confint.
- Add documentation of ci_fct_error_handler.
- Add documentation of ci_fct.
- Update order of formal arguments in CforBenefit. Update default value of n_bootstraps to 999L (only used if CI = "bootstrap". Update default CI value to simple (has low computational cost). Add explicitely arguments match_method and match_distance passed to matchit (... arguments are still passed to matchit).
Add links between odds_ratio_function/freq_function and the repeated variants.
Update the default value of the output argument in freq_function to include "col" in the list of possible inputs, and correct "totalW" to "totalw".
Update the checks of weightvar. When checking the content of the weightvar column of normaldata, a check for NAs are added to the existing check of negative weights.

The warning if negative weights or NAs are present is updated to print the index of consecutive rows in the format "a:b".
Fix bug when output=totalw where the columns starting with "Freqw_total_" are removed instead of those starting with "Freq_row_".
Fix check that n_fold is coercible to a positive integer.

Replace references to the tibble package with references to the dplyr package.

Replace explicit function() with \() when function is volatile.

Add more expressive naming.

Improve inline comments.
Remove note from documentation that only makes sense for binary outcomes. Add a type component to the output, containing information on the input that was provided to the function.
Remove note from documentation that only makes sense for binary outcomes. Add a type component to the output, containing information on the input that was provided to the function.
@kjakobse kjakobse linked an issue Feb 1, 2024 that may be closed by this pull request
Update the default value of the output argument in freq_function to include "col" in the list of possible inputs, and correct "totalW" to "totalw".
This fix is replicates the fix from 5872b16 for freq_function_repeated.
Copy link
Owner

@Laksafoss Laksafoss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we get rid of rlang and tibble entirely?

Copy link
Owner

@Laksafoss Laksafoss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll make it into issues :)

@Laksafoss Laksafoss merged commit 1b2ccce into main Feb 7, 2024
3 checks passed
@kjakobse kjakobse linked an issue Feb 7, 2024 that may be closed by this pull request
@Laksafoss Laksafoss deleted the aso branch February 7, 2024 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid using double curly brackets when they have no effect Avoid using name injection when it is not needed
2 participants