Learn R Programming

distfreereg (version 1.1)

ks.test.compare: Formally compare observed and simulated statistics from a compare object

Description

This is a ks.test method for objects of class compare. It performs a two-sample Kolmogorov--Smirnov test to compare the observed and simulated statistics in an object of class compare.

Usage

# S3 method for compare
ks.test(x, ..., stat = NULL)

Value

A list of the form specified in ks.test.

Arguments

x

Object of class compare.

...

Additional parameters passed to ks.test.

stat

Character string specifying the statistic on which to run the test.

Author

Jesse Miller

Details

When stat is NULL, the default value is the first statistic appearing in the observed_stats element of object.

See Also

compare, distfreereg, ks.test

Examples

Run this code
# In practice, set "reps" larger than 200.
set.seed(20240201)
n <- 100
func <- function(X, theta) theta[1] + theta[2]*X[,1]
Sig <- rWishart(1, df = n, Sigma = diag(n))[,,1]
theta <- c(2,5)
X <- matrix(rexp(n, rate = 1))
cdfr <- compare(true_mean = func, true_X = X, true_covariance = list(Sigma = Sig),
                test_mean = func, X = X, covariance = list(Sigma = Sig), reps = 200,
                prog = Inf, theta = theta, theta_init = rep(1, length(theta)))

ks.test(cdfr)
ks.test(cdfr, stat = "CvM")

Run the code above in your browser using DataLab