I get an error here, which is why it's good practice always to share code with data in the form of a reprex
. See the FAQ: How to do a minimal reproducible example reprex
for beginners.
library(rms)
#> Loading required package: Hmisc
#> Loading required package: lattice
#> Loading required package: survival
#> Loading required package: Formula
#> Loading required package: ggplot2
#>
#> Attaching package: 'Hmisc'
#> The following objects are masked from 'package:base':
#>
#> format.pval, units
#> Loading required package: SparseM
#>
#> Attaching package: 'SparseM'
#> The following object is masked from 'package:base':
#>
#> backsolve
#> Warning in .recacheSubclasses(def@className, def, env): undefined subclass
#> "numericVector" of class "Mnumeric"; definition not updated
final <- structure(list(
percentage = c(
5.5, 72.1, 7.9, 80.6, 56.3, 11.5,
15.3, 12.3, 30.9, 27.5, 0.3, 5.3, 19.6, 19.8, 0.3, 40.5, 16.8,
38, 13.8, 29.9, 15.8, 15.3, 22.8, 17.2, 41.2, 17.2, 31.6, 41.2,
19.6, 38, 41.2, 29.9, 15.3, 29.9, 38, 30.9, 31.6, 15.3, 15.3,
38, 31.6, 41.3, 21.4, 0.4, 41.2, 7.6, 29.9
),
disease = structure(c(
1L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L,
1L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 2L,
2L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L,
2L
), .Label = c("none", "disease"), class = "factor")
), row.names = c(
NA,
-47L
), class = "data.frame")
fit <- lrm(formula = disease ~ rcs(percentage, 4), data = final)
summary(fit)
#> Error in summary.rms(fit): adjustment values not defined here or with datadist for percentage