R Under development (unstable) (2024-07-15 r86902 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > ## test checks and settings > > library("cotram") Loading required package: tram Loading required package: mlt Loading required package: basefun Loading required package: variables Loading required package: mvtnorm > set.seed(25) > > y <- 0L:100L > x <- runif(length(y)) > > yp1 <- y + 1L > d <- data.frame(y = y, x = x) > > m <- cotram(y ~ x, log_first = TRUE) Model was fitted to log(y + 1). > > mm <- cotram(y ~ x, log_first = FALSE) > > ## ---- checks for y > 0 and y %% 1 == 0 ---- > > ## quick check that it returns a error for non-positive & non-integers > .check_error <- function(expr) stopifnot(class(try(expr)) == "try-error") > > ## negative y > ym <- -y > .check_error(cotram(ym ~ x)) Error in cotram(ym ~ x) : response is non-positive > > ## non-integer y > yn <- y/2 > .check_error(cotram(yn ~ x)) Error in cotram(yn ~ x) : response is non-integer > > .check_error(logLik(mm, newdata = data.frame(y = ym, x = x))) Error in logLik.cotram(mm, newdata = data.frame(y = ym, x = x)) : response is non-positive > .check_error(logLik(mm, newdata = data.frame(y = yn, x = x))) Error in logLik.cotram(mm, newdata = data.frame(y = yn, x = x)) : response is non-integer > > .check_error(predict(mm, newdata = data.frame(y = ym, x = x))) Error in predict.cotram(mm, newdata = data.frame(y = ym, x = x)) : response is non-positive > .check_error(predict(mm, newdata = data.frame(y = yn, x = x))) Error in predict.cotram(mm, newdata = data.frame(y = yn, x = x)) : response is non-integer > > .check_error(plot(mm, newdata = data.frame(y = ym, x = x))) Error in predict.cotram(x, newdata = newdata, type = type, q = q, smooth = smooth, : response is non-positive > .check_error(plot(mm, newdata = data.frame(y = yn, x = x))) Error in predict.cotram(x, newdata = newdata, type = type, q = q, smooth = smooth, : response is non-integer > > .check_error(confband(mm, q = ym, newdata = model.frame(mm))) Error in confband.cotram(object = object, newdata = newdata[i, , drop = FALSE], : q is non-positive > .check_error(confband(mm, q = yn, newdata = model.frame(mm))) Error in confband.cotram(object = object, newdata = newdata[i, , drop = FALSE], : q is non-integer > > .check_error(plot(mm, q = ym, newdata = model.frame(mm))) Error in predict.cotram(x, newdata = newdata, type = type, q = q, smooth = smooth, : q is non-positive > .check_error(plot(mm, q = yn, newdata = model.frame(mm))) Error in predict.cotram(x, newdata = newdata, type = type, q = q, smooth = smooth, : q is non-integer > > proc.time() user system elapsed 2.07 0.35 2.45