Skip to content

Commit

Permalink
Automated build.
Browse files Browse the repository at this point in the history
Files changed:
A	.Rbuildignore
A	.github/linters/.lintr
A	.setup/build/betaDelta.pdf
A	.setup/build/betaDelta_1.0.3.9000.tar.gz
A	.setup/latex/bib/quarto.bib
A	.setup/lint/.lintr
A	CITATION.cff
M	DESCRIPTION
A	LICENSE
A	LICENSE.md
A	NAMESPACE
A	R/betaSandwich-jacobian-diff-beta-star-wrt-beta-star-dot.R
A	R/dataSets-nas1982.R
A	R/deltaMethod-acov-delta.R
A	R/deltaMethod-delta-generic.R
A	R/gammaADF-gamma-adf-consistent-dot.R
A	R/gammaADF-gamma-adf-unbiased-dot.R
A	R/gammaN-gamma-mvn-dot.R
A	R/linearAlgebra-d-mat-dot.R
A	R/linearAlgebra-d-of-mat-dot.R
A	R/linearAlgebra-diag-of-vech-dot.R
A	R/linearAlgebra-pinv-of-d-mat-dot.R
A	R/linearAlgebra-vec-dot.R
A	R/linearAlgebra-vech-dot.R
A	R/linearAlgebra-vech-names-dot.R
A	R/processLM-dif-dot.R
A	R/processLM-process-lm-dot.R
A	R/rhoMatrix-rho-of-sigma-dot.R
A	R/strRegression-beta-star-of-rho-dot.R
A	R/strRegression-jacobian-beta-star-wrt-vech-sigma-dot.R
A	R/strRegression-moments-index-dot.R
A	R/strRegression-p-cor-sq-dot.R
A	R/strRegression-r-sq-bar-dot.R
A	R/strRegression-r-sq-of-sigma-dot.R
A	R/strRegression-s-p-cor-dot.R
A	R/wald-ci-wald-dot.R
A	R/wald-probs-of-alpha-dot.R
A	README.md
M	data/nas1982.rda
A	man/BetaDelta.Rd
A	man/DeltaGeneric.Rd
A	man/DiffBetaDelta.Rd
A	man/betaDelta-package.Rd
A	man/coef.betadelta.Rd
A	man/coef.diffbetadelta.Rd
A	man/confint.betadelta.Rd
A	man/confint.diffbetadelta.Rd
A	man/nas1982.Rd
A	man/print.betadelta.Rd
A	man/print.diffbetadelta.Rd
A	man/summary.betadelta.Rd
A	man/summary.diffbetadelta.Rd
A	man/vcov.betadelta.Rd
A	man/vcov.diffbetadelta.Rd
M	project.Rproj
A	vignettes/example_beta_delta.Rmd
A	vignettes/example_diff_beta_delta.Rmd
A	vignettes/vignettes.bib
  • Loading branch information
jeksterslab committed Oct 21, 2023
1 parent ed1bb6e commit 7178668
Show file tree
Hide file tree
Showing 58 changed files with 5,336 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.*\.Rcheck$
.*\.Rproj$
^CITATION\.cff$
^LICENSE\.md$
^Makefile$
^README\.Rmd$
^README\.md$
^\.Rproj\.user$
^\.devcontainer$
^\.git.*$
^\.library$
^\.setup$
^\.sim$
^detritus$
^index\.qmd$
^pkgdown$
^quarto$
^scripts$
^vignettes$
6 changes: 6 additions & 0 deletions .github/linters/.lintr
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
linters: lintr::linters_with_defaults(lintr::object_name_linter(styles = c("CamelCase", "snake_case", "symbols")))
exclusions: list("R/RcppExports.R")
exclude: "# Exclude Linting"
exclude_start: "# Begin Exclude Linting"
exclude_end: "# End Exclude Linting"

Binary file added .setup/build/betaDelta.pdf
Binary file not shown.
Binary file added .setup/build/betaDelta_1.0.3.9000.tar.gz
Binary file not shown.
11 changes: 11 additions & 0 deletions .setup/latex/bib/quarto.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@Article{Wright-1918,
author = {Sewall Wright},
date = {1918-07},
journaltitle = {Genetics},
title = {On the nature of size factors},
doi = {10.1093/genetics/3.4.367},
number = {4},
pages = {367--374},
volume = {3},
publisher = {Oxford University Press ({OUP})},
}
6 changes: 6 additions & 0 deletions .setup/lint/.lintr
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
linters: lintr::linters_with_defaults(lintr::object_name_linter(styles = c("CamelCase", "snake_case", "symbols")))
exclusions: list("R/RcppExports.R")
exclude: "# Exclude Linting"
exclude_start: "# Begin Exclude Linting"
exclude_end: "# End Exclude Linting"

57 changes: 57 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# -----------------------------------------------------------
# CITATION file created with {cffr} R package, v0.5.0
# See also: https://docs.ropensci.org/cffr/
# -----------------------------------------------------------

cff-version: 1.2.0
message: 'To cite package "betaDelta" in publications use:'
type: software
license: MIT
title: 'betaDelta: Confidence Intervals for Standardized Regression Coefficients'
version: 1.0.3.9000
doi: 10.1080/00273171.2023.2201277
abstract: Generates confidence intervals for standardized regression coefficients
using delta method standard errors for models fitted by lm() as described in Yuan
and Chan (2011) <doi:10.1007/s11336-011-9224-6> and Jones and Waller (2015) <doi:10.1007/s11336-013-9380-y>.
A description of the package and code examples are presented in Pesigan, Sun, and
Cheung (2023) <doi:10.1080/00273171.2023.2201277>.
authors:
- family-names: Pesigan
given-names: Ivan Jacob Agaloos
email: r.jeksterslab@gmail.com
orcid: https://orcid.org/0000-0003-4818-8420
preferred-citation:
type: article
title: 'betaDelta and betaSandwich: Confidence intervals for standardized regression
coefficients in R'
authors:
- family-names: Pesigan
given-names: Ivan Jacob Agaloos
email: r.jeksterslab@gmail.com
orcid: https://orcid.org/0000-0003-4818-8420
- family-names: Sun
given-names: Rongwei
email: irissun_s@hotmail.com
orcid: https://orcid.org/0000-0003-0034-1422
- family-names: Cheung
given-names: Shu Fai
email: shufai.cheung@gmail.com
orcid: https://orcid.org/0000-0002-9871-9448
year: '2023'
doi: 10.1080/00273171.2023.2201277
journal: Multivariate Behavioral Research
notes: R package version 1.0.3.9000
repository: https://packagemanager.rstudio.com/all/__linux__/jammy/latest/
repository-code: https://github.com/jeksterslab/betaDelta
url: https://jeksterslab.github.io/betaDelta/
contact:
- family-names: Pesigan
given-names: Ivan Jacob Agaloos
email: r.jeksterslab@gmail.com
orcid: https://orcid.org/0000-0003-4818-8420
keywords:
- confidence-intervals
- delta-method-standard-errors
- r
- r-package
- standardized-regression-coefficients
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ Suggests:
rmarkdown,
testthat,
betaSandwich
RoxygenNote: 7.2.3
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
YEAR: 2023
COPYRIGHT HOLDER: Ivan Jacob Agaloos Pesigan
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2023 Ivan Jacob Agaloos Pesigan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
16 changes: 16 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by roxygen2: do not edit by hand

S3method(coef,betadelta)
S3method(coef,diffbetadelta)
S3method(confint,betadelta)
S3method(confint,diffbetadelta)
S3method(print,betadelta)
S3method(print,diffbetadelta)
S3method(summary,betadelta)
S3method(summary,diffbetadelta)
S3method(vcov,betadelta)
S3method(vcov,diffbetadelta)
export(BetaDelta)
export(DeltaGeneric)
export(DiffBetaDelta)
importFrom(numDeriv,jacobian)
26 changes: 26 additions & 0 deletions R/betaSandwich-jacobian-diff-beta-star-wrt-beta-star-dot.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#' Jacobian Matrix of Differences of Standardized Regression Slopes
#' with Respect to the Standardized Regression Slopes
#'
#' @author Ivan Jacob Agaloos Pesigan
#'
#' @param p positive integer.
#' Number of regressors.
#'
#' @family Beta Sandwich Functions
#' @keywords betaSandwich derivatives internal
#' @noRd
.JacobianDiffBetaStar <- function(p) {
idx <- utils::combn(seq_len(p), 2)
q <- dim(idx)[2]
out <- matrix(
data = 0,
nrow = q,
ncol = p
)
for (i in seq_len(q)) {
j <- idx[, i]
out[i, j[1]] <- 1
out[i, j[2]] <- -1
}
return(out)
}
23 changes: 23 additions & 0 deletions R/dataSets-nas1982.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#' 1982 National Academy of Sciences Doctoral Programs Data
#'
#' @format Ratings of 46 doctoral programs in psychology in the USA
#' with the following variables:
#' \describe{
#' \item{QUALITY}{Program quality ratings.}
#' \item{NFACUL}{Number of faculty members in the program.}
#' \item{NGRADS}{Number of program graduates.}
#' \item{PCTSUPP}{Percentage of program graduates who received support.}
#' \item{PCTGRT}{Percent of faculty members holding research grants.}
#' \item{NARTIC}{Number of published articles
#' attributed to program faculty member.}
#' \item{PCTPUB}{Percent of faculty with one or more published article.}
#' }
#' @references
#' National Research Council. (1982).
#' *An assessment of research-doctorate programs in the United States:
#' Social and behavioral sciences*.
#' \doi{10.17226/9781}.
#' Reproduced with permission from the National Academy of Sciences,
#' Courtesy of the National Academies Press, Washington, D.C.
#' @keywords data
"nas1982"
20 changes: 20 additions & 0 deletions R/deltaMethod-acov-delta.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#' Delta Method Asymptotic Covariance Matrix
#'
#' @author Ivan Jacob Agaloos Pesigan
#'
#' @param jcap Numeric matrix.
#' Jacobian matrix.
#' @param acov Numeric matrix.
#' Asymptotic covariance matrix.
#' @family Delta Method Functions
#' @keywords deltaMethod acov internal
#' @noRd
.ACovDelta <- function(jcap,
acov) {
return(
jcap %*% tcrossprod(
acov,
jcap
)
)
}
104 changes: 104 additions & 0 deletions R/deltaMethod-delta-generic.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#' Delta Method Confidence Intervals (Generic)
#'
#' @author Ivan Jacob Agaloos Pesigan
#'
#' @return Returns a numeric matrix with the following variables:
#' \describe{
#' \item{est}{Estimates}
#' \item{se}{Standard errors}
#' \item{t or z}{Test statistics}
#' \item{p}{p value}
#' \item{ci}{Confidence intervals}
#' }
#' Note that if `test = TRUE`, the `ci` columns are omitted.
#'
#' @param func An R function the input of which is `mu`.
#' The function should return a vector of any length.
#'
#' @param mu Numeric vector.
#' Input of `func`.
#' @param sigmacap Numeric vector or matrix.
#' Asymptotic covariance matrix of `mu`.
#' @param n Sample size.
#' @param theta Numeric vector.
#' Parameter values when the null hypothesis is true.
#' @param alpha Numeric vector.
#' Significance level/s.
#' @param z Logical.
#' If `z = TRUE`,
#' use the standard normal distribution.
#' If `z = FALSE`,
#' use the t distribution.
#' @param df Numeric.
#' Degrees of freedom if `z = FALSE`.
#' @param test Logical.
#' If `TRUE`,
#' return only the results of hypothesis tests.
#' If `FALSE`,
#' return both results of hypothesis tests and confidence intervals.
#'
#' @examples
#' g <- function(x) {
#' 1 / x
#' }
#' mu <- 100
#' sigmasq <- 225
#' n <- 30
#' DeltaGeneric(
#' func = g,
#' mu = mu,
#' sigmacap = sigmasq,
#' n = n
#' )
#' @importFrom numDeriv jacobian
#' @export
#' @family Delta Method Functions
#' @keywords deltaMethod
DeltaGeneric <- function(func,
mu,
sigmacap,
n,
theta = 0,
alpha = c(0.05, 0.01, 0.001),
z = TRUE,
df,
test = FALSE) {
stopifnot(
is.vector(mu)
)
stopifnot(
is.vector(sigmacap) | is.matrix(sigmacap)
)
k <- length(mu)
j <- numDeriv::jacobian(
func = func,
x = mu
)
if (k == 1) {
# univariate
sigmacap <- as.vector(sigmacap)
stopifnot(length(sigmacap) == 1)
vcov <- j^2 * (sigmacap / n)
se <- as.vector(sqrt(vcov))
} else {
# multivariate
stopifnot(
sigmacap == t(sigmacap),
dim(sigmacap)[1] == k
)
vcov <- j %*% (sigmacap / n) %*% t(j)
se <- as.vector(sqrt(diag(vcov)))
}
est <- func(mu)
return(
.CIWald(
est = est,
se = se,
theta = theta,
alpha = alpha,
z = z,
df = df,
test = test
)
)
}
42 changes: 42 additions & 0 deletions R/gammaADF-gamma-adf-consistent-dot.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#' Asymptotic Covariance Matrix of the Sample Covariance Matrix
#' (Asymptotic Distribution Free - Consistent)
#'
#' @author Ivan Jacob Agaloos Pesigan
#'
#' @param d Numeric matrix.
#' Deviation scores.
#' @param vechsigmacap_consistent Numeric vector.
#' Half-vectorization of the consistent covariance matrix.
#' @param n Integer.
#' Sample size.
#'
#' @family gammaADF Functions
#' @keywords gammaADF gamma internal
#' @noRd
.GammaADFConsistent <- function(d,
vechsigmacap_consistent,
n) {
return(
(
(1 / n) * (
Reduce(
f = `+`,
x = lapply(
X = 1:n,
FUN = function(i,
d) {
tcrossprod(
.Vech(
tcrossprod(d[i, ])
)
)
},
d = d
)
)
)
) - tcrossprod(
vechsigmacap_consistent
)
)
}

0 comments on commit 7178668

Please sign in to comment.