R Under development (unstable) (2024-03-03 r86036 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. > # This file is part of the standard setup for testthat. > # It is recommended that you do not modify it. > # > # Where should you do additional test configuration? > # Learn more about the roles of various files in: > # * https://r-pkgs.org/testing-design.html#sec-tests-files-overview > # * https://testthat.r-lib.org/articles/special-files.html > > library(testthat) > library(TCPMOR) > > # Generate simulated data dataC > dataC <- createData() > > # Fit the semi-parametric model > spm.fit <- fitSemiParamModel(dataC) iteration 1 iteration 2 iteration 3 iteration 4 > plot(spm.fit,ylab = "logit π",xlab = "age",shade = FALSE) > summary(spm.fit) Summary for non-linear components: df spar knots f(dataC$age) 5.25 55.83 34 Note this includes 1 df for the intercept. > > # Find two cut-off points > dataC <- findCutoffs(spm.fit, dataC) > > # Calculate the two cut-off points after limiting sensitivity se and specificity sp > result <- calculateCutoffs(dataC) > cutoffs <- result$cutoffs > dataC2 <- result$filteredData > print(cutoffs) [1] 32.26711 65.35335 > > # Discretize age variable based on the two cutoffs > dataC2 <- discretizeAge(dataC2, cutoffs) > > # Fitting logistic regression models and obtaining OR values and 95% confidence intervals > OR_Results <- fitLogisticRegression(dataC2) > print(round(OR_Results, 3)) OR 2.5 % 97.5 % (Intercept) 0.188 0.055 0.643 age_p 5.610 1.633 19.266 > > proc.time() user system elapsed 228.39 3.84 232.25