R Under development (unstable) (2024-03-22 r86169 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(200) > > # Fit the semi-parametric model > spm.fit <- fitSemiParamModel(dataC) iteration 1 iteration 2 iteration 3 iteration 4 iteration 5 > plot(spm.fit,ylab = "lnOR",xlab = "age",shade = FALSE) > summary(spm.fit) Summary for non-linear components: df spar knots f(dataC$age) 2.849 53.19 39 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.00421 64.42158 > > # 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.333 0.035 3.205 age_p 3.474 0.354 34.093 > > proc.time() user system elapsed 1.21 0.17 1.37