| Title: | Mediation Analysis Confidence Intervals |
|---|---|
| Description: | Computes confidence intervals for nonlinear functions of model parameters (e.g., product of k coefficients) in single-level and multilevel structural equation models. Methods include the distribution of the product, Monte Carlo simulation, and bootstrap methods. It also performs the Model-Based Constrained Optimization (MBCO) procedure for hypothesis testing of indirect effects. References: Tofighi, D., and MacKinnon, D. P. (2011). RMediation: An R package for mediation analysis confidence intervals. Behavior Research Methods, 43, 692-700. <doi:10.3758/s13428-011-0076-x>; Tofighi, D., and Kelley, K. (2020). Improved inference in mediation analysis: Introducing the model-based constrained optimization procedure. Psychological Methods, 25(4), 496-515. <doi:10.1037/met0000259>; Tofighi, D. (2020). Bootstrap Model-Based Constrained Optimization Tests of Indirect Effects. Frontiers in Psychology, 10, 2989. <doi:10.3389/fpsyg.2019.02989>. |
| Authors: | Davood Tofighi [aut, cre] (ORCID: <https://orcid.org/0000-0001-8523-7776>) |
| Maintainer: | Davood Tofighi <[email protected]> |
| License: | GPL (>= 3) | file LICENSE |
| Version: | 1.4.0 |
| Built: | 2026-05-16 07:50:48 UTC |
| Source: | https://github.com/data-wise/rmediation |
Generic function for computing cumulative distribution function.
cdf(object, ...)cdf(object, ...)
object |
A distribution object. |
... |
Additional arguments passed to methods. |
Generic function for computing confidence intervals.
ci(mu, ...)ci(mu, ...)
mu |
A distribution object or numeric vector of means. |
... |
Additional arguments passed to methods. |
Computes confidence intervals for the indirect effect from a medfit MediationData object using RMediation's methods (DOP, Monte Carlo, etc.).
ci_mediation_data(mu, level = 0.95, type = "dop", n.mc = 1e+05, ...) ci_serial_mediation_data(mu, level = 0.95, type = "MC", n.mc = 1e+05, ...)ci_mediation_data(mu, level = 0.95, type = "dop", n.mc = 1e+05, ...) ci_serial_mediation_data(mu, level = 0.95, type = "MC", n.mc = 1e+05, ...)
mu |
A MediationData object from the medfit package |
level |
Confidence level (default 0.95 for 95% CI) |
type |
Type of CI method: "dop" (Distribution of Product), "MC" (Monte Carlo), or "asymp" (asymptotic normal) |
n.mc |
Number of Monte Carlo samples (for type = "MC") |
... |
Additional arguments passed to underlying methods |
This method extracts the a and b path coefficients from the MediationData object, along with their standard errors and covariance, and computes confidence intervals using RMediation's methods.
"dop": Distribution of Product method. Uses the exact or approximate distribution of the product of two normal random variables. Recommended for most applications.
"MC": Monte Carlo simulation. Samples from the joint distribution
of a and b to estimate the CI. Use n.mc to control precision.
"asymp": Asymptotic normal approximation using the delta method. Fast but may be inaccurate for small samples or non-normal distributions.
A list with components:
CI |
The confidence interval (lower, upper) |
Estimate |
Point estimate of indirect effect (a*b) |
SE |
Standard error of indirect effect |
type |
Method used for CI computation |
ci for the generic function,
MediationData for the input class,
ProductNormal for the underlying distribution class
## Not run: library(medfit) library(RMediation) # Fit mediation models fit_m <- lm(M ~ X + C, data = mydata) fit_y <- lm(Y ~ X + M + C, data = mydata) # Extract mediation structure med_data <- extract_mediation(fit_m, model_y = fit_y, treatment = "X", mediator = "M") # Compute CI using Distribution of Product ci(med_data, type = "dop") # Compute CI using Monte Carlo ci(med_data, type = "MC", n.mc = 10000) ## End(Not run)## Not run: library(medfit) library(RMediation) # Fit mediation models fit_m <- lm(M ~ X + C, data = mydata) fit_y <- lm(Y ~ X + M + C, data = mydata) # Extract mediation structure med_data <- extract_mediation(fit_m, model_y = fit_y, treatment = "X", mediator = "M") # Compute CI using Distribution of Product ci(med_data, type = "dop") # Compute CI using Monte Carlo ci(med_data, type = "MC", n.mc = 10000) ## End(Not run)
Compute quantiles for distribution objects. This function computes quantiles
for product normal distributions, not data quantiles (use stats::quantile
for data).
dist_quantile(object, ...)dist_quantile(object, ...)
object |
A distribution object (e.g., ProductNormal). |
... |
Additional arguments passed to methods. |
Method to check if ProductNormal object is properly specified for computation
is_valid_for_computation(object)is_valid_for_computation(object)
object |
A ProductNormal object |
TRUE if object is valid for computation methods
This function computes asymptotic MBCO chi-squared test for a smooth function of model parameters including a function of indirect effects.
mbco(h0, h1, ...)mbco(h0, h1, ...)
h0 |
An |
h1 |
An |
... |
Additional arguments. |
An object of class MBCOResult containing
statistic |
asymptotic chi-squared test statistic value |
df |
chi-squared df |
p_value |
chi-squared p-value computed based on the method specified by the argument |
type |
The type of test performed |
Davood Tofighi [email protected]
## Not run: data(memory_exp) memory_exp$x <- as.numeric(memory_exp$x)-1 # manually creating dummy codes endVar <- c('x', 'repetition', 'imagery', 'recall') manifests <- c('x', 'repetition', 'imagery', 'recall') full_model <- OpenMx::mxModel( "memory_example", type = "RAM", manifestVars = manifests, OpenMx::mxPath( from = "x", to = endVar, arrows = 1, free = TRUE, values = .2, labels = c("a1", "a2", "cp") ), OpenMx::mxPath( from = 'repetition', to = 'recall', arrows = 1, free = TRUE, values = .2, labels = 'b1' ), OpenMx::mxPath( from = 'imagery', to = 'recall', arrows = 1, free = TRUE, values = .2, labels = "b2" ), OpenMx::mxPath( from = manifests, arrows = 2, free = TRUE, values = .8 ), OpenMx::mxPath( from = "one", to = endVar, arrows = 1, free = TRUE, values = .1 ), OpenMx::mxAlgebra(a1 * b1, name = "ind1"), OpenMx::mxAlgebra(a2 * b2, name = "ind2"), OpenMx::mxCI("ind1", type = "both"), OpenMx::mxCI("ind2", type = "both"), OpenMx::mxData(observed = memory_exp, type = "raw") ) ## Reduced Model for indirect effect: a1*b1 null_model1 <- OpenMx::mxModel( model= full_model, name = "Null Model 1", OpenMx::mxConstraint(ind1 == 0, name = "ind1_eq0_constr") ) full_model <- OpenMx::mxTryHard(full_model, checkHess=FALSE, silent = TRUE ) null_model1 <- OpenMx::mxTryHard(null_model1, checkHess=FALSE, silent = TRUE ) mbco(null_model1,full_model) ## End(Not run)## Not run: data(memory_exp) memory_exp$x <- as.numeric(memory_exp$x)-1 # manually creating dummy codes endVar <- c('x', 'repetition', 'imagery', 'recall') manifests <- c('x', 'repetition', 'imagery', 'recall') full_model <- OpenMx::mxModel( "memory_example", type = "RAM", manifestVars = manifests, OpenMx::mxPath( from = "x", to = endVar, arrows = 1, free = TRUE, values = .2, labels = c("a1", "a2", "cp") ), OpenMx::mxPath( from = 'repetition', to = 'recall', arrows = 1, free = TRUE, values = .2, labels = 'b1' ), OpenMx::mxPath( from = 'imagery', to = 'recall', arrows = 1, free = TRUE, values = .2, labels = "b2" ), OpenMx::mxPath( from = manifests, arrows = 2, free = TRUE, values = .8 ), OpenMx::mxPath( from = "one", to = endVar, arrows = 1, free = TRUE, values = .1 ), OpenMx::mxAlgebra(a1 * b1, name = "ind1"), OpenMx::mxAlgebra(a2 * b2, name = "ind2"), OpenMx::mxCI("ind1", type = "both"), OpenMx::mxCI("ind2", type = "both"), OpenMx::mxData(observed = memory_exp, type = "raw") ) ## Reduced Model for indirect effect: a1*b1 null_model1 <- OpenMx::mxModel( model= full_model, name = "Null Model 1", OpenMx::mxConstraint(ind1 == 0, name = "ind1_eq0_constr") ) full_model <- OpenMx::mxTryHard(full_model, checkHess=FALSE, silent = TRUE ) null_model1 <- OpenMx::mxTryHard(null_model1, checkHess=FALSE, silent = TRUE ) mbco(null_model1,full_model) ## End(Not run)
A class representing the results of a Model-Based Constrained Optimization (MBCO) test.
MBCOResult( statistic = integer(0), df = integer(0), p_value = integer(0), type = character(0) )MBCOResult( statistic = integer(0), df = integer(0), p_value = integer(0), type = character(0) )
statistic |
Numeric test statistic value. |
df |
Numeric degrees of freedom. |
p_value |
Numeric p-value. |
type |
Character string indicating the type of test. |
Produces confidence intervals for the mediated effect and the product of two normal random variables
Produces confidence intervals for the mediated effect and the product of two normal random variables
medci( mu.x, mu.y, se.x, se.y, rho = 0, alpha = 0.05, type = "dop", plot = FALSE, plotCI = FALSE, n.mc = 1e+05, ... ) medci( mu.x, mu.y, se.x, se.y, rho = 0, alpha = 0.05, type = "dop", plot = FALSE, plotCI = FALSE, n.mc = 1e+05, ... )medci( mu.x, mu.y, se.x, se.y, rho = 0, alpha = 0.05, type = "dop", plot = FALSE, plotCI = FALSE, n.mc = 1e+05, ... ) medci( mu.x, mu.y, se.x, se.y, rho = 0, alpha = 0.05, type = "dop", plot = FALSE, plotCI = FALSE, n.mc = 1e+05, ... )
mu.x |
mean of |
mu.y |
mean of |
se.x |
standard error (deviation) of |
se.y |
standard error (deviation) of |
rho |
correlation between |
alpha |
significance level for the confidence interval. The default value is .05. |
type |
method used to compute confidence interval. It takes on the
values |
plot |
when |
plotCI |
when |
n.mc |
when |
... |
additional arguments to be passed on to the function. |
This function returns a confidence interval at significance level
for the mediated effect (product of two normal random
variables). To obtain a confidence interval using a specific method, the
argument type should be specified. The default is type="dop", which uses the code
we wrote in R to implement the distribution of product of the coefficients
method described by Meeker and Escobar (1994) to evaluate the CDF of the
distribution of product. type="MC" uses the Monte Carlo approach to
compute the confidence interval (Tofighi & MacKinnon, 2011).
type="asymp" produces the asymptotic normal confidence interval.
Note that except for the Monte Carlo method, the standard error for the
indirect effect is based on the analytical results by Craig (1936):
where and are the standard errors of and ,
respectively. In addition, the estimate of the indirect effect is
, where is the covariance between
and . The argument type="all" prints confidence intervals
using all available methods.
This function returns a ()% confidence interval for
the mediated effect (product of two normal random variables). To obtain a
confidence interval using a specific method, the argument type
should be specified. The default is type="dop", which uses the code
we wrote in R to implement the distribution of product of the coefficients
method described by Meeker and Escobar (1994) to evaluate the CDF of the
distribution of product. type="MC" uses the Monte Carlo approach to
compute the confidence interval (Tofighi & MacKinnon, 2011).
type="asymp" produces the asymptotic normal confidence interval.
Note that except for the Monte Carlo method, the standard error for the
indirect effect is based on the analytical results by Craig (1936):
. In addition, the estimate of
indirect effect is ; type="all" prints
confidence intervals using all four options.
A vector of lower confidence limit and upper confidence limit. When
type is "prodclin" (default), "DOP", "MC" or
"asymp", medci returns a list that contains:
CI |
a vector of lower and upper confidence limits (at significance
level |
Estimate |
a point estimate of the quantity of interest, |
SE |
standard error of the quantity of interest, |
MC Error |
When |
Note that when type="all", medci returns a list of
four objects, each of which a list that contains the results
produced by each method as described above.
A vector of lower confidence limit and upper confidence limit. When
type is "prodclin" (default), "DOP", "MC" or
"asymp", medci returns a list that contains:
(\eqn{1-\alpha})% CI |
a vector of lower and upper confidence limits, |
Estimate |
a point estimate of the quantity of interest, |
SE |
standard error of the quantity of interest, |
MC Error |
When
|
Note that when
type="all", medci returns a list of four
objects, each of which a list that contains the results produced by
each method as described above.
Davood Tofighi [email protected]
Craig, C. C. (1936). On the frequency function of .
The Annals of Mathematical Statistics, 7, 1–15.
MacKinnon, D. P., Fritz, M. S., Williams, J., and Lockwood, C. M. (2007). Distribution of the product confidence limits for the indirect effect: Program PRODCLIN. Behavior Research Methods, 39, 384–389.
Meeker, W. and Escobar, L. (1994). An algorithm to compute the CDF of the product of two normal random variables. Communications in Statistics: Simulation and Computation, 23, 271–280.
Tofighi, D. and MacKinnon, D. P. (2011). RMediation: An R package for mediation analysis confidence intervals. Behavior Research Methods, 43, 692–700. doi:10.3758/s13428-011-0076-x
Craig, C. C. (1936). On the frequency function of .
The Annals of Mathematical Statistics, 7, 1–15.
MacKinnon, D. P., Fritz, M. S., Williams, J., and Lockwood, C. M. (2007). Distribution of the product confidence limits for the indirect effect: Program PRODCLIN. Behavior Research Methods, 39, 384–389.
Meeker, W. and Escobar, L. (1994). An algorithm to compute the CDF of the product of two normal random variables. Communications in Statistics: Simulation and Computation, 23, 271–280.
Tofighi, D. and MacKinnon, D. P. (2011). RMediation: An R package for mediation analysis confidence intervals. Behavior Research Methods, 43, 692–700. doi:10.3758/s13428-011-0076-x
qprodnormal pprodnormal ci
RMediation-package
qprodnormal pprodnormal ci
RMediation-package
## Example 1 res <- medci( mu.x = .2, mu.y = .4, se.x = 1, se.y = 1, rho = 0, alpha = .05, type = "dop", plot = TRUE, plotCI = TRUE ) ## Example 2 res <- medci(mu.x = .2, mu.y = .4, se.x = 1, se.y = 1, rho = 0, alpha = .05, type = "all", plot = TRUE, plotCI = TRUE) ## Example 1 res <- medci( mu.x = .2, mu.y = .4, se.x = 1, se.y = 1, rho = 0, alpha = .05, type = "dop", plot = TRUE, plotCI = TRUE ) ## Example 2 res <- medci(mu.x = .2, mu.y = .4, se.x = 1, se.y = 1, rho = 0, alpha = .05, type = "all", plot = TRUE, plotCI = TRUE)## Example 1 res <- medci( mu.x = .2, mu.y = .4, se.x = 1, se.y = 1, rho = 0, alpha = .05, type = "dop", plot = TRUE, plotCI = TRUE ) ## Example 2 res <- medci(mu.x = .2, mu.y = .4, se.x = 1, se.y = 1, rho = 0, alpha = .05, type = "all", plot = TRUE, plotCI = TRUE) ## Example 1 res <- medci( mu.x = .2, mu.y = .4, se.x = 1, se.y = 1, rho = 0, alpha = .05, type = "dop", plot = TRUE, plotCI = TRUE ) ## Example 2 res <- medci(mu.x = .2, mu.y = .4, se.x = 1, se.y = 1, rho = 0, alpha = .05, type = "all", plot = TRUE, plotCI = TRUE)
Data were obtained from eight replicated experiments. The data were collected on the first day of class as part of the first Dr. MacKinnon's (2018) classroom teaching. The pedagogical value of the experiment was that students would have first-hand knowledge of the experiment thereby increasing their understanding of course concepts. Permission to use the data was obtained from the university Institutional Review Board.
data(memory_exp)data(memory_exp)
A data frame with 369 rows and 5 variables:
Replication ID, ranges from 1 to 8
Use of repetition rehearsal technique, ranges from 1 to 12
Total words recalled out of 20 words, ranges from 3 to 20
Use of imagery rehearsal technique on a 1 to 9 scale
A factor with two levels: "repetition" (primary rehearsal) or "imagery" (secondary rehearsal)
If you use the data set, please cite the original article by MacKinnon et al. (2018) cited below.
MacKinnon, D. P., Valente, M. J., & Wurpts, I. C. (2018). Benchmark validation of statistical models: Application to mediation analysis of imagery and memory. Psychological Methods, 23, 654–671. doi:10.1037/met0000174
This function returns a probability corresponding to the quantile q.
pMC(q, mu, Sigma, quant, lower.tail = TRUE, n.mc = 1e+05, ...)pMC(q, mu, Sigma, quant, lower.tail = TRUE, n.mc = 1e+05, ...)
q |
quantile |
mu |
a vector of means (e.g., coefficient estimates) for the normal random variables. A user can assign a name to each mean value, e.g., |
Sigma |
either a covariance matrix or a vector that stacks all the columns of the lower triangle variance–covariance matrix one underneath the other. |
quant |
quantity of interest, which is a nonlinear/linear function of the model parameters. Argument |
lower.tail |
logical; if |
n.mc |
Monte Carlo sample size (default: 1e5). Larger values provide more precision but take longer to compute. |
... |
additional arguments. |
scalar probability value.
Davood Tofighi [email protected]
Tofighi, D. and MacKinnon, D. P. (2011). RMediation: An R package for mediation analysis confidence intervals. Behavior Research Methods, 43, 692–700. doi:10.3758/s13428-011-0076-x
pMC(.2, mu = c(b1 = 1, b2 = .7, b3 = .6, b4 = .45), Sigma = c(.05, 0, 0, 0, .05, 0, 0, .03, 0, .03), quant = ~ b1 * b2 * b3 * b4 )pMC(.2, mu = c(b1 = 1, b2 = .7, b3 = .6, b4 = .45), Sigma = c(.05, 0, 0, 0, .05, 0, 0, .03, 0, .03), quant = ~ b1 * b2 * b3 * b4 )
Generates percentiles (100 based quantiles) for the distribution of product of two normal random variables and the mediated effect
pprodnormal( q, mu.x, mu.y, se.x = 1, se.y = 1, rho = 0, lower.tail = TRUE, type = "dop", n.mc = 1e+05 )pprodnormal( q, mu.x, mu.y, se.x = 1, se.y = 1, rho = 0, lower.tail = TRUE, type = "dop", n.mc = 1e+05 )
q |
quantile or value of the product |
mu.x |
mean of |
mu.y |
mean of |
se.x |
standard error (deviation) of |
se.y |
standard error (deviation) of |
rho |
correlation between |
lower.tail |
logical; if |
type |
method used to compute confidence interval. It takes on the
values |
n.mc |
Monte Carlo sample size when |
This function returns the percentile (probability) and the
associated error for the distribution of product of mediated effect (two
normal random variables). To obtain a percentile using a specific method,
the argument type should be specified. The default method is
type="dop", which is based on the method described by Meeker and
Escobar (1994) to evaluate the CDF of the distribution of product of two
normal random variables. type="MC" uses the Monte Carlo approach
(Tofighi & MacKinnon, 2011). type="all" prints percentiles using all
three options. For the method type="dop", the error is the modulus
of absolute error for the numerical integration (for more information see
Meeker and Escobar, 1994). For type="MC", the error refers to the
Monte Carlo error.
An object of the type list that contains the
following values:
p |
probability (percentile) corresponding to
quantile |
error |
estimate of the absolute error |
Davood Tofighi [email protected]
Tofighi, D. and MacKinnon, D. P. (2011). RMediation: An R package for mediation analysis confidence intervals. Behavior Research Methods, 43, 692–700. doi:10.3758/s13428-011-0076-x
pprodnormal(q = 0, mu.x = .5, mu.y = .3, se.x = 1, se.y = 1, rho = 0, type = "all")pprodnormal(q = 0, mu.x = .5, mu.y = .3, se.x = 1, se.y = 1, rho = 0, type = "all")
Represents the distribution of the product of normal random variables.
ProductNormal(mu = integer(0), Sigma = integer(0))ProductNormal(mu = integer(0), Sigma = integer(0))
mu |
Numeric vector of means. |
Sigma |
Covariance matrix. |
Utility function to create ProductNormal from lavaan parameter estimates
ProductNormal_from_lavaan(lavaan_model, param_names)ProductNormal_from_lavaan(lavaan_model, param_names)
lavaan_model |
A fitted lavaan model object |
param_names |
Names of parameters to include in the product (e.g., c("a", "b")) |
A ProductNormal object
Enhanced ProductNormal constructor with better validation
ProductNormal2(mu, Sigma, validate = TRUE)ProductNormal2(mu, Sigma, validate = TRUE)
mu |
Numeric vector of means |
Sigma |
Covariance matrix |
validate |
Whether to run additional validation (default: TRUE) |
This function returns a quantile corresponding to the probability p.
qMC(p, mu, Sigma, quant, n.mc = 1e+05, ...)qMC(p, mu, Sigma, quant, n.mc = 1e+05, ...)
p |
probability. |
mu |
a vector of means (e.g., coefficient estimates) for the normal random variables. A user can assign a name to each mean value, e.g., |
Sigma |
either a covariance matrix or a vector that stacks all the columns of the lower triangle variance–covariance matrix one underneath the other. |
quant |
quantity of interest, which is a nonlinear/linear function of the model parameters. Argument |
n.mc |
Monte Carlo sample size (default: 1e5). Larger values provide more precision but take longer to compute. |
... |
additional arguments. |
scalar quantile value.
Davood Tofighi [email protected]
Tofighi, D. and MacKinnon, D. P. (2011). RMediation: An R package for mediation analysis confidence intervals. Behavior Research Methods, 43, 692–700. doi:10.3758/s13428-011-0076-x
qMC(.05, mu = c(b1 = 1, b2 = .7, b3 = .6, b4 = .45), Sigma = c(.05, 0, 0, 0, .05, 0, 0, .03, 0, .03), quant = ~ b1 * b2 * b3 * b4 )qMC(.05, mu = c(b1 = 1, b2 = .7, b3 = .6, b4 = .45), Sigma = c(.05, 0, 0, 0, .05, 0, 0, .03, 0, .03), quant = ~ b1 * b2 * b3 * b4 )
Generates quantiles for the distribution of product of two normal random variables
qprodnormal( p, mu.x, mu.y, se.x, se.y, rho = 0, lower.tail = TRUE, type = "dop", n.mc = 1e+05 )qprodnormal( p, mu.x, mu.y, se.x, se.y, rho = 0, lower.tail = TRUE, type = "dop", n.mc = 1e+05 )
p |
probability |
mu.x |
mean of |
mu.y |
mean of |
se.x |
standard error (deviation) of |
se.y |
standard error (deviation) of |
rho |
correlation between |
lower.tail |
logical; if |
type |
method used to compute confidence interval. It takes on the
values |
n.mc |
Monte Carlo sample size when |
This function returns a quantile and the associated error
(accuracy) corresponding the requested percentile (probability) p of
the distribution of product of mediated effect (product of two normal
random variables). To obtain a quantile using a specific method, the
argument type should be specified. The default method is
type="dop", which uses the method described by Meeker and Escobar
(1994) to evaluate the CDF of the distribution of product of two normal
variables. type="MC" uses the Monte Carlo approach (Tofighi &
MacKinnon, 2011). type="all" prints quantiles using all three
options. For the method type="dop", the error is the modulus of
absolute error for the numerical integration (for more information see
Meeker and Escobar, 1994). For type="MC", the error refers to the
Monte Carlo error.
An object of the type list that contains the
following values:
q |
quantile corresponding to probability |
error |
estimate of the absolute error |
Davood Tofighi [email protected]
Tofighi, D. and MacKinnon, D. P. (2011). RMediation: An R package for mediation analysis confidence intervals. Behavior Research Methods, 43, 692–700. doi:10.3758/s13428-011-0076-x
## lower tail qprodnormal( p = .1, mu.x = .5, mu.y = .3, se.x = 1, se.y = 1, rho = 0, lower.tail = TRUE, type = "all" ) ## upper tail qprodnormal( p = .1, mu.x = .5, mu.y = .3, se.x = 1, se.y = 1, rho = 0, lower.tail = FALSE, type = "all" )## lower tail qprodnormal( p = .1, mu.x = .5, mu.y = .3, se.x = 1, se.y = 1, rho = 0, lower.tail = TRUE, type = "all" ) ## upper tail qprodnormal( p = .1, mu.x = .5, mu.y = .3, se.x = 1, se.y = 1, rho = 0, lower.tail = FALSE, type = "all" )
Tidy generic function
tidy(x, ...)tidy(x, ...)
x |
An object to tidy |
... |
Additional arguments passed to methods |
A tibble or data.frame with tidy output
Creates a data.frame for a log-likelihood object
## S3 method for class 'logLik' tidy(x, ...)## S3 method for class 'logLik' tidy(x, ...)
x |
x A log-likelihood object, typically returned by logLik. |
... |
Additional arguments (not used) |
A data.frame with columns:
The term name
The log-likelihood value
The degrees of freedom
Davood Tofighi [email protected]
fit <- lm(mpg ~ wt, data = mtcars) logLik_fit <- logLik(fit) tidy(logLik_fit)fit <- lm(mpg ~ wt, data = mtcars) logLik_fit <- logLik(fit) tidy(logLik_fit)
Enhanced validation and utility functions for ProductNormal class
Additional validation for ProductNormal objects
validate_ProductNormal(object, verbose = FALSE)validate_ProductNormal(object, verbose = FALSE)
object |
A ProductNormal object |
verbose |
Whether to show detailed validation messages |
TRUE if valid, throws error if invalid