Skip to contents

This class inherits from TestStatistic and implements a function to calculate the test statistic (and x-y-values that can be used to plot the underlying process).

The process underlying the test statistic is defined by $$\tilde{\alpha}_n^{KM}(t) = \sqrt{n} \left( \hat{F}^{KM}_n(t) - \frac{1}{n} \sum_{i=1}^n F(t|\hat{\vartheta}_n, X_i) \right), \quad -\infty \le t \le \infty.$$

Super class

gofreg::TestStatistic -> CondKolmY_RCM

Methods

Inherited methods


Method calc_stat()

Calculate the value of the test statistic for given data and a model to test for.

Usage

CondKolmY_RCM$calc_stat(data, model)

Arguments

data

data.frame() with columns x and y containing the data

model

ParamRegrModel to test for, already fitted to the data

Returns

The modified object (self), allowing for method chaining.


Method clone()

The objects of this class are cloneable with this method.

Usage

CondKolmY_RCM$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# Create an example dataset
n <- 100
x <- cbind(runif(n), rbinom(n, 1, 0.5))
model <- NormalGLM$new()
y <- model$sample_yx(x, params=list(beta=c(2,3), sd=1))
c <- rnorm(n, mean(y)*1.2, sd(y)*0.5)
data <- dplyr::tibble(x = x, z = pmin(y,c), delta = as.numeric(y <= c))

# Fit the correct model
model$fit(data, params_init=list(beta=c(1,1), sd=3), inplace = TRUE, loglik = loglik_xzd)

# Print value of test statistic and plot corresponding process
ts <- CondKolmY_RCM$new()
ts$calc_stat(data, model)
print(ts)
#> Test statistic with value 0.8832506
plot(ts)


# Fit a wrong model
model2 <- NormalGLM$new(linkinv = function(u) {u+10})
model2$fit(data, params_init=list(beta=c(1,1), sd=3), inplace = TRUE, loglik = loglik_xzd)

# Print value of test statistic and plot corresponding process
ts2 <- CondKolmY_RCM$new()
ts2$calc_stat(data, model2)
print(ts2)
#> Test statistic with value 4.557321
plot(ts2)