MEP | R Documentation |
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 given in Dikta & Scheer (2021) \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/978-3-030-73480-0")} and defined by
\bar{R}^1_n(u)
= \frac{1}{\sqrt{n}} \sum_{i=1}^n \left( Y_i - m(X_i, \hat{\beta}_n)
\right) I_{\{\hat{\beta}_n X_i \le u\}}, \quad -\infty \le u \le \infty.
gofreg::TestStatistic
-> MEP
calc_stat()
Calculate the value of the test statistic for given data and a model to test for.
MEP$calc_stat(data, model)
data
data.frame()
with columns x and y containing the data
model
ParamRegrModel to test for
The modified object (self
), allowing for method chaining.
clone()
The objects of this class are cloneable with this method.
MEP$clone(deep = FALSE)
deep
Whether to make a deep clone.
# 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))
data <- dplyr::tibble(x = x, y = y)
# Fit the correct model
model$fit(data, params_init=list(beta=c(1,1), sd=3), inplace = TRUE)
# Print value of test statistic and plot corresponding process
ts <- MEP$new()
ts$calc_stat(data, model)
print(ts)
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)
# Print value of test statistic and plot corresponding process
ts2 <- MEP$new()
ts2$calc_stat(data, model2)
print(ts2)
plot(ts2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.