Title: | Mathijs Deen's Miscellaneous Auxiliaries |
---|---|
Description: | Provides a variety of functions useful for data analysis, selection, manipulation, and graphics. |
Authors: | Mathijs Deen [aut, cre] |
Maintainer: | Mathijs Deen <[email protected]> |
License: | GPL-3 |
Version: | 1.1.0 |
Built: | 2024-11-22 04:22:14 UTC |
Source: | https://github.com/mathijsdeen/mdma |
Return which values are in a certain range
%inRange%
indicates which values are in a certain range, including the
boundaries of the range.
lhs %inRange% rhs
lhs %inRange% rhs
lhs |
numeric vector. |
rhs |
numeric vector of length 2 with the bounds of the range. |
%inRange%
returns a logical vector of length(lhs)
, indicating which
values of lhs
are and are not in range rhs
. Boundaries of rhs
are included.
Mathijs Deen
a <- seq(0, 100, 5) r <- c(40, 70) cbind(a, 'a %inRange% r' = a %inRange% r, 'a %withinRange% r' = a %withinRange% r)
a <- seq(0, 100, 5) r <- c(40, 70) cbind(a, 'a %inRange% r' = a %inRange% r, 'a %withinRange% r' = a %withinRange% r)
Evaluates whether the left hand side argument is not in the right hand side argument.
lhs %ni% rhs
lhs %ni% rhs
lhs |
left hand side. |
rhs |
right hand side. |
The %ni%
function negates the %in%
operator.
The function returns a vector of the same length as lhs
.
Mathijs Deen
c(1,2,3) %ni% c(1,2)
c(1,2,3) %ni% c(1,2)
Return which values are within a certain range
%withinRange%
indicates which values are in a certain range, excluding
the boundaries of the range.
lhs %withinRange% rhs
lhs %withinRange% rhs
lhs |
numeric vector. |
rhs |
numeric vector of length 2 with the bounds of the range. |
%withinRange%
returns a logical vector of length(lhs)
, indicating which
values of lhs
are and are not in range rhs
. Boundaries of rhs
are excluded.
Mathijs Deen
a <- seq(0, 100, 5) r <- c(40, 70) cbind(a, 'a %inRange% r' = a %inRange% r, 'a %withinRange% r' = a %withinRange% r)
a <- seq(0, 100, 5) r <- c(40, 70) cbind(a, 'a %inRange% r' = a %inRange% r, 'a %withinRange% r' = a %withinRange% r)
Calculate the area under the curve.
auc(x, ...)
auc(x, ...)
x |
object of class |
... |
other arguments (none are used at the moment). |
returns the area under the curve for a roc
class object.
Mathijs Deen
a <- roc(QIDS$QIDS, QIDS$depression, c("Yes","No"), "Yes") auc(a)
a <- roc(QIDS$QIDS, QIDS$depression, c("Yes","No"), "Yes") auc(a)
Perform checks for a linear model regarding influential cases and collinearity numerically and graphically.
check(object, ...)
check(object, ...)
object |
object of class |
... |
other parameters (none are used at the moment). |
check
returns a list containing two matrices with statistics regarding
influential cases and a vector of variance inflation factors. Furthermore, it
produces diagnostics plots.
The return list contains three elements:
- influence
, a data.frame
, with observations in the model,
and the following variables:
predicted.value |
The value predicted by the model. |
residual |
The raw residual. |
std.residual |
The standardized residual. |
dfb.<...> |
DFBETAs for the variables in the model. |
dffit |
DFFIT value. |
cov.r |
Covariance ratio, a measure of change in the determinant of the coefficient covariance matrix. |
cook.d |
Cook's distance. |
hat |
Hat values. |
influential |
Determines whether a case is influential on any of the
measures |
- is.infl
is a data.frame
indicating which influence measure(s)
is/are flagged per observation.
- vifs
, a vector containing variance inflation factors for the
variables in the model.
By default, the two data.frame
s regarding influence measures only give the influence
measures for cases that are flagged as being influential. Influence measures for all cases
can be queried using print.check.lm
.
The generated plots are the plots produced by plot.lm
, numbers 1 through 6.
For the influence indicators, the following rules are applied to check whether a case is influential:
.
.
.
.
These indicators for being an influential case were derived from
influence.measures
in the stats
package.
Mathijs Deen
lm.1 <- lm(mpg ~ disp + wt, data = mtcars) check(lm.1)
lm.1 <- lm(mpg ~ disp + wt, data = mtcars) check(lm.1)
Show odds ratios and their confidence intervals for logistic regression parameter estimates.
coefsLogReg(model, confint = TRUE, level = 0.95)
coefsLogReg(model, confint = TRUE, level = 0.95)
model |
object of class |
confint |
indicates whether a confidence interval for the odds ratio should be returned. |
level |
the confidence level required. |
coefsLogReg
returns the same table as summary(object)$coefficients
,
with the addition of the coefficients' odds ratios and their confidence intervals.
Mathijs Deen
glm(formula = am ~ disp, family = binomial, data = mtcars) |> coefsLogReg()
glm(formula = am ~ disp, family = binomial, data = mtcars) |> coefsLogReg()
List all correlations in a correlation matrix without duplicates.
corList(x, ...)
corList(x, ...)
x |
a numeric vector, matrix or data frame. |
... |
arguments passed to the |
corList
returns a list of correlations
Mathijs Deen
mtcars[,c("mpg","disp", "hp", "drat", "wt", "qsec")] |> corList(method="spearman")
mtcars[,c("mpg","disp", "hp", "drat", "wt", "qsec")] |> corList(method="spearman")
dPPC2
calculates an effect size for studies with
pretest and posttest scores for two groups, usually a treatment and
a control group. It is based on Morris (2008), who based it on Becker (1988).
dPPC2(preT, posT, preC, posC, correct = TRUE, CIlevel = 0.95)
dPPC2(preT, posT, preC, posC, correct = TRUE, CIlevel = 0.95)
preT |
pre-scores for treatment group. |
posT |
post-scores for treatment group. |
preC |
pre-scores for control group. |
posC |
post-scores for control group. |
correct |
indicates whether a correction factor should be calculated (i.e., Hedges' g instead of Cohen's d). |
CIlevel |
the confidence level required. |
dPPC2
returns a vector of length 6, containing:
d |
the effect size estimate. |
SE |
the standard error of the effect sie estimate. |
lower.bound |
lower bound of the confidence interval. |
upper.bound |
upper bound of the confidence interval. |
NT |
sample size of treatment group. |
NC |
sample size of control group. |
Mathijs Deen
Becker, B.J. (1988). Synthesizing standardized mean-change measures. British Journal of Mathematical and Statistical Psychology, 41, 257-278.
Morris, S.B. (2008). Estimating effect sizes from pretest-posttest-control group designs. Organizational Research Methods, 11, 364-386.
library(MASS) set.seed(1) treatment <- mvrnorm(n=50, mu=c(50,40), Sigma = matrix(c(100,70,70,100), ncol=2), empirical = TRUE) control <- mvrnorm(n=50, mu=c(50,45), Sigma = matrix(c(100,70,70,100), ncol=2), empirical = TRUE) dPPC2(treatment[,1], treatment[,2], control[,1], control[,2])
library(MASS) set.seed(1) treatment <- mvrnorm(n=50, mu=c(50,40), Sigma = matrix(c(100,70,70,100), ncol=2), empirical = TRUE) control <- mvrnorm(n=50, mu=c(50,45), Sigma = matrix(c(100,70,70,100), ncol=2), empirical = TRUE) dPPC2(treatment[,1], treatment[,2], control[,1], control[,2])
Display frequency table with percentages and cumulative percentages.
frequencies(x)
frequencies(x)
x |
vector of values. |
object of type data.frame
containing frequencies, percentages and cumulative percentages.
Mathijs Deen
frequencies(datasets::mtcars$carb)
frequencies(datasets::mtcars$carb)
keep
saves an object to a new object. This is useful
if one wants to save an intermediate result when using pipes.
keep(object, name, pos = 1, envir = as.environment(pos), inherits = FALSE)
keep(object, name, pos = 1, envir = as.environment(pos), inherits = FALSE)
object |
the object that is to be saved into |
name |
the name of the new object, containing the value of |
pos |
where to do the assignment. See |
envir |
the environment to use. See |
inherits |
should the enclosing framss of the environment be inspected?
See |
Upon saving object
to name
, the value of object
is
returned. This makes it suitable for pipes.
Mathijs Deen
mtcars |> lm(mpg ~ disp + hp, data = _) |> keep(lm.mpg_disp_hp) |> summary()
mtcars |> lm(mpg ~ disp + hp, data = _) |> keep(lm.mpg_disp_hp) |> summary()
Mean center a vector or numeric matrix.
m(x)
m(x)
x |
a numeric matrix or vector. |
This function resembles base::scale.default
, with the scale
argument set to FALSE
. This, together with the short function name, is
especially useful when you want to mean center variables in an analysis (e.g.,
using (g)lm
), but you dont want the long form scale(x, scale=FALSE)
to clutter up the rownames of the parameter estimates or the model anova.
m
returns a mean centered version of x
. If x
is
a matrix, the matrix dimensions are preserved.
Mathijs Deen
vals <- matrix(rnorm(24, 15, 10), ncol = 2) m(vals)
vals <- matrix(rnorm(24, 15, 10), ncol = 2) m(vals)
Plot the effects of the antecedent as a function of the moderator.
## S3 method for class 'probeInteraction' plot( x, ..., col.JN = "red", lty.JN = "dotted", col.CI = rgb(red = 0.5, green = 0.5, blue = 0.5, alpha = 0.2), lty.CI = "longdash", lty.0 = "dotted" )
## S3 method for class 'probeInteraction' plot( x, ..., col.JN = "red", lty.JN = "dotted", col.CI = rgb(red = 0.5, green = 0.5, blue = 0.5, alpha = 0.2), lty.CI = "longdash", lty.0 = "dotted" )
x |
object of class |
... |
other arguments (none are used). |
col.JN |
color for Johnson-Neyman cut-off line(s). |
lty.JN |
linetype for Johnson-Neyman cut-off line(s). |
col.CI |
color of the shade for the confidence interval. |
lty.CI |
linetype for confidence interval boundaries. |
lty.0 |
linetype for the horizontal line where the effect of the focal predictor on the outcome equals 0. |
plot.probeInteraction
returns a combined plot with p value on the
first y axis and effect of the antecedent variable.
Mathijs Deen
lm.1 <- lm(mpg ~ hp * wt, data = mtcars) pI.1 <- probeInteraction(lm.1, hp, wt, JN=TRUE, n.interval.moderator = 3, quantile.moderator = c(0.1,0.9), values.moderator = 2) plot(pI.1) lm.2 <- lm(mpg ~ qsec * drat, data = mtcars) pI.2 <- probeInteraction(lm.2, qsec, drat, JN=TRUE, n.interval.moderator = 30, quantile.moderator = c(0.1,0.9), values.moderator = 2) plot(pI.2)
lm.1 <- lm(mpg ~ hp * wt, data = mtcars) pI.1 <- probeInteraction(lm.1, hp, wt, JN=TRUE, n.interval.moderator = 3, quantile.moderator = c(0.1,0.9), values.moderator = 2) plot(pI.1) lm.2 <- lm(mpg ~ qsec * drat, data = mtcars) pI.2 <- probeInteraction(lm.2, qsec, drat, JN=TRUE, n.interval.moderator = 30, quantile.moderator = c(0.1,0.9), values.moderator = 2) plot(pI.2)
Plot an ROC curve.
## S3 method for class 'roc' plot( x, y, which = 1:3, orientation = c("horizontal", "vertical"), cutoffs.1 = NULL, cutoffs.2 = NULL, cutoffs.3 = NULL, xlab.3 = NULL, labels.3 = NULL, xlim.3 = NULL, ylim.3 = c(0, 10), pos.legend.2 = "right", pos.legend.3 = "topright", ... )
## S3 method for class 'roc' plot( x, y, which = 1:3, orientation = c("horizontal", "vertical"), cutoffs.1 = NULL, cutoffs.2 = NULL, cutoffs.3 = NULL, xlab.3 = NULL, labels.3 = NULL, xlim.3 = NULL, ylim.3 = c(0, 10), pos.legend.2 = "right", pos.legend.3 = "topright", ... )
x |
object of class |
y |
argument for generic |
which |
which plots to show (see Details). |
orientation |
indicate whether the plots should be arranged horizontally or vertically. |
cutoffs.1 |
cutoff value(s) to be shown in the first plot. |
cutoffs.2 |
cutoff value(s) to be shown in the second plot. |
cutoffs.3 |
cutoff value(s) to be shown in the third plot. |
xlab.3 |
lable for x axis in third plot. |
labels.3 |
legend labels for third plot. |
xlim.3 |
xlim for third plot. |
ylim.3 |
ylim for third plot. |
pos.legend.2 |
legend position for second plot. |
pos.legend.3 |
legend position for third plot. |
... |
other arguments for generic |
plot.roc
provides three plots:
The first plot contains the ROC curve.
The second plot contains curves for the sensitivity and the specificity for all threshold values.
The third plot contains density plots for the two classification groups.
Mathijs Deen
a <- roc(QIDS$QIDS, QIDS$depression, c("Yes","No"), "Yes") plot(a, ylim.3 = c(0,.2), xlab.3= "QIDS value", cutoffs.1 = 14.5, cutoffs.2 = 14.5, cutoffs.3 = 14.5)
a <- roc(QIDS$QIDS, QIDS$depression, c("Yes","No"), "Yes") plot(a, ylim.3 = c(0,.2), xlab.3= "QIDS value", cutoffs.1 = 14.5, cutoffs.2 = 14.5, cutoffs.3 = 14.5)
Plot the density function of certain probability distributions.
plotDistribution( distribution = c("normal", "t", "chi2", "F"), xRange = c(0, 5), xColArea = NULL, xAreaCol = NULL, mean = 0, sd = 1, df, df1, df2, ncp, ... )
plotDistribution( distribution = c("normal", "t", "chi2", "F"), xRange = c(0, 5), xColArea = NULL, xAreaCol = NULL, mean = 0, sd = 1, df, df1, df2, ncp, ... )
distribution |
the probability distribution for which a plot should be drawn. Currently,
the options are |
xRange |
Range of x axis over which the distribution should be drawn. |
xColArea |
Optional, a matrix with two columns, where each row contains lower and upper bounds for intervals that should be colored under the pdf curve. |
xAreaCol |
Optional, should contain (a) color(s) for the interval colors in |
mean |
mean for the normal distribution. |
sd |
sd for the normal distribution. |
df |
df for the t distribution. |
df1 |
first df for the F distribution. |
df2 |
second df for the F distribution. |
ncp |
non-centrality parameter |
... |
other arguments to be forwarded to the |
plotDistribution
returns a probability density plot.
Mathijs Deen
plotDistribution(distribution = "normal", xRange = c(-5, 5), xColArea = matrix(data = c(-5, -1.96, 1.96, 5), ncol = 2, byrow = TRUE), xAreaCol = c("green", "blue"), mean = 0, sd = 1, yaxt = "n", ylab = "")
plotDistribution(distribution = "normal", xRange = c(-5, 5), xColArea = matrix(data = c(-5, -1.96, 1.96, 5), ncol = 2, byrow = TRUE), xAreaCol = c("green", "blue"), mean = 0, sd = 1, yaxt = "n", ylab = "")
Calculate the posterior model odds for a set of models.
posteriorModelOdds(...)
posteriorModelOdds(...)
... |
objects of class |
Posterior model odds are calculated for every model as
where the minimal BIC value is subtracted from all BICs. In other words: the model with the lowest BIC has .
posteriorModelOdds
returns to posterior model odds for the models provided.
Mathijs Deen
lm.1 <- lm(mpg ~ hp + wt, data = mtcars) lm.2 <- lm(mpg ~ hp * wt, data = mtcars) lm.3 <- lm(mpg ~ hp * wt + gear, data = mtcars) posteriorModelOdds(lm.1, lm.2, lm.3)
lm.1 <- lm(mpg ~ hp + wt, data = mtcars) lm.2 <- lm(mpg ~ hp * wt, data = mtcars) lm.3 <- lm(mpg ~ hp * wt + gear, data = mtcars) posteriorModelOdds(lm.1, lm.2, lm.3)
Print the check of lm object
## S3 method for class 'check.lm' print(x, which.infl = c("influential", "all"), ...)
## S3 method for class 'check.lm' print(x, which.infl = c("influential", "all"), ...)
x |
an object used to select a method. |
which.infl |
Indicate whether only influential cases ( |
... |
further arguments passed to or from other methods (none are used). |
prints the check.lm
object.
Mathijs Deen
lm.1 <- lm(mpg ~ disp + wt, data = mtcars) chk.lm.1 <- check(lm.1) print(chk.lm.1, which.infl="all")
lm.1 <- lm(mpg ~ disp + wt, data = mtcars) chk.lm.1 <- check(lm.1) print(chk.lm.1, which.infl="all")
Print the effects from a probed interaction.
## S3 method for class 'probeInteraction' print(x, ...)
## S3 method for class 'probeInteraction' print(x, ...)
x |
object of class |
... |
other parameters (none are used). |
print.probeInteraction
prints the effects table of a
probeInteraction
object.
Mathijs Deen
lm.1 <- lm(mpg ~ hp * wt, data = mtcars) pI <- probeInteraction(lm.1, hp, wt, JN=TRUE, n.interval.moderator = 3, quantile.moderator = c(0.1,0.9), values.moderator = 2) print(pI)
lm.1 <- lm(mpg ~ hp * wt, data = mtcars) pI <- probeInteraction(lm.1, hp, wt, JN=TRUE, n.interval.moderator = 3, quantile.moderator = c(0.1,0.9), values.moderator = 2) print(pI)
Print the output of a t test.
## S3 method for class 'tTest' print(x, ...)
## S3 method for class 'tTest' print(x, ...)
x |
an object used to select a method. |
... |
further arguments passed to or from other methods. |
prints the tTest
object as a htest
object.
Mathijs Deen
x1 <- QIDS$QIDS[QIDS$depression == "Yes"] x2 <- QIDS$QIDS[QIDS$depression == "No"] tt <- tTest(x1, x2) print(tt)
x1 <- QIDS$QIDS[QIDS$depression == "Yes"] x2 <- QIDS$QIDS[QIDS$depression == "No"] tt <- tTest(x1, x2) print(tt)
Probe the effect of a moderator on an X/antecedent variable in a linear model.
probeInteraction( object, antecedent, moderator, alpha = 0.05, JN = TRUE, n.interval.moderator, quantile.moderator, values.moderator )
probeInteraction( object, antecedent, moderator, alpha = 0.05, JN = TRUE, n.interval.moderator, quantile.moderator, values.moderator )
object |
object of class |
antecedent |
antecedent (or x) variable in |
moderator |
moderator variable in |
alpha |
desired alpha level for Johnson-Neyman procedure. |
JN |
indicate whether Johnson-Neyman procedure should be carried out. |
n.interval.moderator |
number of intervals in the moderator variable to probe. |
quantile.moderator |
quantile values in the moderator variable to probe. |
values.moderator |
raw values in the moderator variable to probe. |
the arguments n.interval.moderator
, quantile.moderator
and values.moderator
can be combined. All unique values from these methods combined, together with the values from the
Johnson-Neyman procedure (if specified) will be part of the probing procedure.
probeInteraction
returns a data frame containing values of the moderator
in a linear model, the effect of the antecedent at that value of the moderator,
standard errors, t values, p values and a confidence interval.
Mathijs Deen
lm.1 <- lm(mpg ~ hp * wt, data = mtcars) probeInteraction(lm.1, hp, wt, JN=TRUE, n.interval.moderator = 3, quantile.moderator = c(0.1,0.9), values.moderator = 2)
lm.1 <- lm(mpg ~ hp * wt, data = mtcars) probeInteraction(lm.1, hp, wt, JN=TRUE, n.interval.moderator = 3, quantile.moderator = c(0.1,0.9), values.moderator = 2)
The QIDS
dataframe consists of 100 observations of people that were
clinically diagnosed with a major depressive disorder and who filled out the QIDS-SR questionnaire. The data were simulated.
QIDS
QIDS
the following variables are available:
QIDS
: QIDS-SR total score.
Depression
: an indicator whether the individual was diagnosed with a depression or not.
Mathijs Deen
rci
computes the reliable change index according to Jacobson and Truax (1992).
rci(x1, x2, rxx)
rci(x1, x2, rxx)
x1 |
prescore. |
x2 |
postscore, same length as |
rxx |
internal consistency statistic. |
rci
returns a vector of length(x1)
with reliable change index scores.
Mathijs Deen
Jacobson, N.S., & Truax, P. (1992). Clinical significance: a statistical approach to defining meaningful change in psychotherapy research. Journal of Consulting and Clinical Psychology, 59, 12-19.
library(MASS) set.seed(1) q <- mvrnorm(n=120, mu=c(40, 50), Sigma = matrix(c(56.25,45,45,56.25), ncol = 2), empirical = TRUE) cbind(q, rci(q[,1], q[,2], .8), rci(q[,1], q[,2], .8) > 1.96)
library(MASS) set.seed(1) q <- mvrnorm(n=120, mu=c(40, 50), Sigma = matrix(c(56.25,45,45,56.25), ncol = 2), empirical = TRUE) cbind(q, rci(q[,1], q[,2], .8), rci(q[,1], q[,2], .8) > 1.96)
Calculate ROC curve statistics.
roc(response, group, levels, state)
roc(response, group, levels, state)
response |
response variable for which thresholds will be calculated. |
group |
group variable. |
levels |
relevant levels of |
state |
state level of |
Returns a list with the following elements:
data |
|
rdf |
ROC dataframe. This is a |
auc |
Area under the ROC curve. |
response |
Response variable from input data. |
group |
Group variable from the input data. |
levels |
Used levels. |
state |
State level. |
Mathijs Deen
roc(QIDS$QIDS, QIDS$depression, c("No","Yes"), "Yes") |> plot(ylim.3=c(0,.2))
roc(QIDS$QIDS, QIDS$depression, c("No","Yes"), "Yes") |> plot(ylim.3=c(0,.2))
Summarize the outcome of a t test
## S3 method for class 'tTest' summary(object, rnd = 3L, ...)
## S3 method for class 'tTest' summary(object, rnd = 3L, ...)
object |
object of class |
rnd |
number of decimal places. Should have length 1 or 3. One value specifies the rounding value for the degrees of freedom, t statistic and p value all at once, while specifying three values gives the rounding values for the three statistics respectively. |
... |
other arguments of the summary generic (none are used). |
summary.htest
returns a typical APA-like output (without italics) for a t-test.
Mathijs Deen
x1 <- QIDS$QIDS[QIDS$depression == "Yes"] x2 <- QIDS$QIDS[QIDS$depression == "No"] tt <- tTest(x1, x2) summary(tt, rnd = c(1,2,3))
x1 <- QIDS$QIDS[QIDS$depression == "Yes"] x2 <- QIDS$QIDS[QIDS$depression == "No"] tt <- tTest(x1, x2) summary(tt, rnd = c(1,2,3))
perform t tests with the possibility of inputting group statistics.
tTest( x, y = NULL, sdx = NULL, sdy = NULL, nx = length(na.omit(x)), ny = length(na.omit(y)), alternative = c("two.sided", "greater", "less"), mu = 0, paired = FALSE, rxy = NULL, var.equal = FALSE, conf.level = 0.95 )
tTest( x, y = NULL, sdx = NULL, sdy = NULL, nx = length(na.omit(x)), ny = length(na.omit(y)), alternative = c("two.sided", "greater", "less"), mu = 0, paired = FALSE, rxy = NULL, var.equal = FALSE, conf.level = 0.95 )
x |
a numeric vector. Can be of length 1 for a group mean. |
y |
a numeric vector. Should be |
sdx |
standard deviation for |
sdy |
standard deviation for |
nx |
sample size for |
ny |
sample size for |
alternative |
a character string specifying the alternative hypothesis,
must be one of " |
mu |
a number indicating the true value of the mean (or difference in means) if you are performing an independent samples t-test). |
paired |
a logical indicating whether you want a paired t-test. |
rxy |
correlation between two paired samples. |
var.equal |
a logical variable indicating whether to treat the two variances as being equal. If
|
conf.level |
level of the confidence interval. |
tTest
performs a t-test (independent samples, paired samples, one sample) just like base-R t.test, but with the extended possibility to enter group statistics instead of raw data.
Mathijs Deen
library(MASS) set.seed(1) ds <- mvrnorm(n=50, mu = c(50,55), Sigma = matrix(c(100,0,0,81), ncol = 2), empirical = TRUE) |> data.frame() |> setNames(c("x1","x2")) t.test(ds$x1, ds$x2) tTest(x = ds$x1, y = 55, sdy = 9, ny = 50)
library(MASS) set.seed(1) ds <- mvrnorm(n=50, mu = c(50,55), Sigma = matrix(c(100,0,0,81), ncol = 2), empirical = TRUE) |> data.frame() |> setNames(c("x1","x2")) t.test(ds$x1, ds$x2) tTest(x = ds$x1, y = 55, sdy = 9, ny = 50)