formula_points: explore formula of points to each variable

Description Usage Arguments Value Examples

View source: R/formula_points.R

Description

explore the points formula to each variable and get best power.

Usage

1
formula_points(nomogram, power, digits = 6)

Arguments

nomogram

nomogram, after nomogram command in rms package

power

if missing, power will be choose automatically up to 100 based on all R2 equealling to 1

digits

default is 6

Value

a global variable Formula_points, the formula of points and each variable

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
library(rms)
set.seed(2018)
n <-2019
age <- rnorm(n,60,20)
sex <- factor(sample(c('female','male'),n,TRUE))
sex <- as.numeric(sex)
weight <- sample(50:100,n,replace = TRUE)
time <- sample(50:800,n,replace = TRUE)
units(time)="day"
death <- sample(c(1,0,0),n,replace = TRUE)
df <- data.frame(time,death,age,sex,weight)
ddist <- datadist(df)
options(datadist='ddist')
f <- cph(formula(Surv(time,death)~sex+age+weight),data=df,
         x=TRUE,y=TRUE,surv=TRUE,time.inc=3)
surv <- Survival(f)
nomo <- nomogram(f,
                 lp=TRUE,
                 fun=list(function(x) surv(365,x),
                          function(x) surv(365*2,x)),
                 funlabel=c("1-Year Survival Prob",
                            "2-Year Survival Prob"))
library(nomogramFormula)
formula_points(nomogram = nomo)
formula_points(nomogram = nomo,power = 1)
formula_points(nomogram = nomo,power = 2)
formula_points(nomogram = nomo,power = 3,digits=6)

yikeshu0611/nomogramFormula documentation built on Dec. 25, 2019, 11:36 a.m.