Skip to content

Commit f7e0916

Browse files
committed
Merge branch 'master' of https://github.com/tbates/umx
2 parents 6f7e555 + 699dce6 commit f7e0916

36 files changed

+195
-120
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export(SE_from_p)
5858
export(bucks)
5959
export(deg2rad)
6060
export(dl_from_dropbox)
61+
export(fin_NI)
6162
export(fin_interest)
6263
export(fin_percent)
6364
export(fin_valuation)

R/build_run_modify.R

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3785,17 +3785,17 @@ umxSetParameters <- function(model, labels, free = NULL, values = NULL, newlabel
37853785
#' \emph{Tip}: To find labels by name, use the regex parameter of [umxGetParameters()]
37863786
#'
37873787
#' @param model An [mxModel()] within which to equate parameters listed in "a" with those in "b"
3788-
#' @param a one or more parameter labels to equate with b labels
3789-
#' @param b one or more labels to equate (if newNames is not set, these will set to the a labels, thus equating the parameters
3788+
#' @param a one or more labels to equate with those in the "b" set.
3789+
#' @param b one or more labels to equate with those in the 'a' set. (if 'newlabels' is NULL, labels will be set to 'a' list).
37903790
#' @param newlabels (optional) list of new labels for the equated parameters.
3791-
#' @param free Should parameter(s) initially be free? (default = TRUE)
3791+
#' @param free Must the parameter(s) initially be free? (default = TRUE)
37923792
#' @param verbose Whether to give verbose feedback (default = TRUE)
37933793
#' @param name name for the returned model (optional: Leave empty to leave name unchanged)
37943794
#' @param comparison Compare the new model to the old (if updating an existing model: default = TRUE)
37953795
#' @param autoRun Whether to run the model (default), or just to create it and return without running.
37963796
#' @param tryHard Default ('no') uses normal mxRun. "yes" uses mxTryHard. Other options: "ordinal", "search"
3797-
#' @param master A list of "master" labels to which slave labels will be equated
3798-
#' @param slave A list of slave labels which will be updated to match master labels, thus equating the parameters
3797+
#' @param master synonym for 'a'
3798+
#' @param slave synonym for 'b'
37993799
#' @return - [mxModel()]
38003800
#' @export
38013801
#' @seealso [umxModify()], [umxCompare()]
@@ -4996,21 +4996,20 @@ umxPath <- function(from = NULL, to = NULL, with = NULL, var = NULL, cov = NULL,
49964996
#'
49974997
#' @docType package
49984998
#' @name umx
4999-
#' @family Teaching and testing Functions
50004999
#' @family Core Model Building Functions
50015000
#' @family Model Summary and Comparison
5002-
#' @family Summary Functions
50035001
#' @family Reporting Functions
5004-
#' @family Plotting functions
50055002
#' @family Super-easy helpers
50065003
#' @family Twin Modeling Functions
50075004
#' @family Twin Data functions
5005+
#' @family Miscellaneous Stats Functions
5006+
#' @family Teaching and testing Functions
50085007
#' @family Get and set
50095008
#' @family Check or test
5009+
#' @family Plotting functions
50105010
#' @family Data Functions
50115011
#' @family File Functions
50125012
#' @family String Functions
5013-
#' @family Miscellaneous Stats Helpers
50145013
#' @family Miscellaneous Utility Functions
50155014
#' @family datasets
50165015
#' @family Advanced Model Building Functions

R/fit_and_reporting.R

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ umxDiagnose <- function(model, tryHard = FALSE, diagonalizeExpCov = FALSE){
7979
#' @param digits (default 2)
8080
#' @return - Best model
8181
#' @export
82-
#' @family Miscellaneous Stats Helpers
82+
#' @family Miscellaneous Stats Functions
8383
#' @seealso - [AIC()]
8484
#' @references - Wagenmakers E.J., Farrell S. (2004), 192-196. AIC model selection using Akaike weights. *Psychonomic Bulletin and Review*. **11**, 192-196. \url{https://pubmed.ncbi.nlm.nih.gov/15117008/}
8585
#' @md
@@ -1870,10 +1870,8 @@ umxSummary.MxModelGxE <- umxSummaryGxE
18701870
#' (handy for getting tables into Word, and other text systems!)
18711871
#' @param file file to write html too if report = "html" (defaults to "tmp.html")
18721872
#' @param compareWeightedAIC Show the Wagenmakers AIC weighted comparison (default = FALSE)
1873-
#' @family Core Modelling Functions
18741873
#' @family Model Summary and Comparison
1875-
#' @family Summary functions
1876-
#' @seealso - [mxCompare()], [umxSummary()], [umxRAM()],
1874+
#' @seealso - [umxSummary()], [umxRAM()],[mxCompare()]
18771875
#' @references - <https://github.com/tbates/umx>
18781876
#' @export
18791877
#' @md
@@ -3828,7 +3826,7 @@ print.RMSEA <- function(x, ...) {
38283826
#' @param ... More p-values if you want to offer them up one by one instead of wrapping in a vector for `pvalues`
38293827
#' @return - A meta-analytic p-value
38303828
#' @export
3831-
#' @family Miscellaneous Stats Helpers
3829+
#' @family Miscellaneous Stats Functions
38323830
#' @references - Fisher, R.A. (1925). *Statistical Methods for Research Workers*. Oliver and Boyd (Edinburgh). ISBN 0-05-002170-2.
38333831
#' Fisher, R. A (1948). "Questions and answers #14". *The American Statistician*. **2**: 30–31. doi:10.2307/2681650. JSTOR 2681650.
38343832
#' See also Stouffer's method for combining Z scores, which allows weighting.
@@ -3853,7 +3851,7 @@ FishersMethod <- function(pvalues, ...){
38533851
#' @param na.rm remove NAs by default.
38543852
#' @return - Geometric mean of x
38553853
#' @export
3856-
#' @family Miscellaneous Stats Helpers
3854+
#' @family Miscellaneous Stats Functions
38573855
#' @references - <https://en.wikipedia.org/wiki/Geometric_mean>
38583856
#' @md
38593857
#' @examples
@@ -3891,7 +3889,7 @@ geometric_mean = function(x, na.rm = c(TRUE, FALSE)){
38913889
#' @param na.rm remove NAs (default = TRUE).
38923890
#' @return - Harmonic mean of x
38933891
#' @export
3894-
#' @family Miscellaneous Stats Helpers
3892+
#' @family Miscellaneous Stats Functions
38953893
#' @references - <https://en.wikipedia.org/wiki/Harmonic_mean>
38963894
#' @md
38973895
#' @examples
@@ -4524,7 +4522,7 @@ umxSummarizeTwinData <- function(data = NULL, selVars = NULL, sep = "_T", zyg =
45244522
#' @param alternative A two (default) or one-sided (greater less) test.
45254523
#' @return cocor result.
45264524
#' @export
4527-
#' @family Miscellaneous Stats Helpers
4525+
#' @family Miscellaneous Stats Functions
45284526
#' @md
45294527
#' @examples
45304528
#' # Is the correlation of mpg with cylinder count different from that

R/misc_and_utility.R

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,7 +1659,7 @@ umx_pad <- function(x, n) {
16591659
#' @return - object
16601660
#' @export
16611661
#' @seealso - [umx_aggregate()]
1662-
#' @family Miscellaneous Stats Helpers
1662+
#' @family Miscellaneous Stats Functions
16631663
#' @references - <https://tbates.github.io>, <https://github.com/tbates/umx>
16641664
#' @md
16651665
#' @examples
@@ -2591,6 +2591,43 @@ fin_interest <- function(principal = 0, deposits = 0, dinflate = 0, interest = 0
25912591
}
25922592

25932593

2594+
#' Compute NI given annual Earnings.
2595+
#'
2596+
#' @description
2597+
#' Employees pay contributions at 12%% on annual earnings between £9,568 and £50,270. Above that you pay at 2%%.
2598+
#' Employers pay at 13.8%% on all annual earnings of more than £8,840, although there are different thresholds
2599+
#' for those under the age of 21 and for apprentices under the age of 25.
2600+
#'
2601+
#' @details
2602+
#'
2603+
#' @param annualEarnings Employee annual earnings.
2604+
#' @return - NI
2605+
#' @export
2606+
#' @family Miscellaneous Functions
2607+
#' @seealso - [fin_interest()]
2608+
#' @references - <https://www.telegraph.co.uk/tax/tax-hacks/politicians-running-scared-long-overdue-national-insurance-overhaul>
2609+
#' @md
2610+
#' @examples
2611+
#' fin_NI(42e3)
2612+
#' fin_NI(142000)
2613+
#'
2614+
fin_NI <- function(annualEarnings, symbol="£") {
2615+
if(annualEarnings < 50270){
2616+
employee = .12 * max(0, (annualEarnings- 9568))
2617+
} else {
2618+
employee = (.12 * (annualEarnings- 9568)) + (.02 * (annualEarnings-50270))
2619+
}
2620+
employer = .138 * max((annualEarnings - 8840), 0)
2621+
2622+
Total = employer + employee
2623+
class(Total) = 'money'
2624+
attr(Total, 'symbol') <- symbol
2625+
cat(paste0("Employer pays: ", bucks(employer, sym=symbol, cat=FALSE), ", and employee pays ", bucks(employee, sym=symbol, cat=FALSE),
2626+
". so ", round((employer+employee)/annualEarnings*100, 2), "%\n")
2627+
)
2628+
return(Total)
2629+
}
2630+
25942631
#' Compute the percent change needed to return to the original value after percent off (or on).
25952632
#'
25962633
#' @description
@@ -2915,7 +2952,7 @@ umxPlotFun <- function(fun= dnorm, min= -1, max= 5, xlab = NULL, ylab = NULL, ti
29152952
#' @param alpha for CI (default = 0.05)
29162953
#' @return - List of odds in group 1 and group2, and the resulting OR and CI
29172954
#' @export
2918-
#' @family Miscellaneous Stats Helpers
2955+
#' @family Miscellaneous Stats Functions
29192956
#' @seealso - [umx_r_test()]
29202957
#' @references - <https://github.com/tbates/umx>, <https://tbates.github.io>
29212958
#' @md
@@ -3011,7 +3048,7 @@ print.oddsratio <- function(x, digits = 3, ...) {
30113048
#' @param type Unused argument for future directions
30123049
#' @return - Matrix of correlations and p-values
30133050
#' @seealso umxHetCor
3014-
#' @family Miscellaneous Stats Helpers
3051+
#' @family Miscellaneous Stats Functions
30153052
#' @export
30163053
#' @references - <https://github.com/tbates/umx>
30173054
#' @md
@@ -3074,7 +3111,7 @@ rowMin <- function(df, na.rm= TRUE) {
30743111
#' @param digits how many digits to round to (defaults to getOption("digits"))
30753112
#' @param coerce whether to make the column numeric if it is not (default = FALSE)
30763113
#' @return - [mxModel()]
3077-
#' @family Miscellaneous Stats Helpers
3114+
#' @family Miscellaneous Stats Functions
30783115
#' @export
30793116
#' @references - <https://github.com/tbates/umx>
30803117
#' @md
@@ -3126,7 +3163,7 @@ umx_round <- function(df, digits = getOption("digits"), coerce = FALSE) {
31263163
#' @param upper Upper CI
31273164
#' @return - Standard error
31283165
#' @export
3129-
#' @family Miscellaneous Stats Helpers
3166+
#' @family Miscellaneous Stats Functions
31303167
#' @seealso - [umxAPA()]
31313168
#' @md
31323169
#' @examples
@@ -3173,7 +3210,7 @@ specify_decimal <- function(x, k){
31733210
#' @param S A square, symmetric, numeric covariance matrix
31743211
#' @return None
31753212
#' @export
3176-
#' @family Miscellaneous Stats Helpers
3213+
#' @family Miscellaneous Stats Functions
31773214
#' @seealso - [umx::print.reliability()],
31783215
#' @references - <https://cran.r-project.org/package=Rcmdr>
31793216
#' @examples
@@ -4188,7 +4225,7 @@ umx_check_names <- function(namesNeeded, data = NA, die = TRUE, no_others = FALS
41884225
#' @param allowCorForFactorCovs When ordinal data are present, use heterochoric correlations in affected cells, in place of covariances.
41894226
#' @return - [mxModel()]
41904227
#' @export
4191-
#' @family Miscellaneous Stats Helpers
4228+
#' @family Miscellaneous Stats Functions
41924229
#' @references - <https://tbates.github.io>
41934230
#' @md
41944231
#' @examples
@@ -4318,7 +4355,7 @@ umx_lower.tri <- function(x, diag=FALSE){
43184355
#' @param na.rm passed to mean - defaults to "na.rm"
43194356
#' @return - frame of means
43204357
#' @export
4321-
#' @family Miscellaneous Stats Helpers
4358+
#' @family Miscellaneous Stats Functions
43224359
#' @examples
43234360
#' tmp = mtcars[,1:4]
43244361
#' tmp$cyl = ordered(mtcars$cyl) # ordered factor
@@ -5031,7 +5068,7 @@ umx_string_to_algebra <- function(algString, name = NA, dimnames = NA) {
50315068
#' @return - new dataframe with scaled variables
50325069
#' @export
50335070
#' @seealso umx_scale_wide_twin_data scale
5034-
#' @family Miscellaneous Stats Helpers
5071+
#' @family Miscellaneous Stats Functions
50355072
#' @references - <https://github.com/tbates/umx>
50365073
#' @md
50375074
#' @examples
@@ -5759,7 +5796,7 @@ umx_rot <- function(vec, na.last=FALSE){
57595796
#' @param x something that cov2cor can work on (matrix, df, etc.)
57605797
#' @return - A correlation matrix
57615798
#' @export
5762-
#' @family Miscellaneous Stats Helpers
5799+
#' @family Miscellaneous Stats Functions
57635800
#' @seealso [cov2cor()]
57645801
#' @references - <https://github.com/tbates/umx>
57655802
#' @examples
@@ -7344,7 +7381,7 @@ xmu_make_bin_cont_pair_data <- function(data, vars = NULL, suffixes=NULL){
73447381
#' @param std.err Compute the SEs? (default = FALSE)
73457382
#' @return - A matrix of correlations
73467383
#' @family Data Functions
7347-
#' @family Miscellaneous Stats Helpers
7384+
#' @family Miscellaneous Stats Functions
73487385
#' @export
73497386
#' @md
73507387
#' @examples

man/FishersMethod.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/SE_from_p.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/deg2rad.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/fin_NI.Rd

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/fin_interest.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/fin_percent.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)