

dear：David Winsemius
   in  the  example（nomogram），I don't understand the meanings of the program which have been  marked by red line.And how to compile the program.(L <- .4*(sex=='male') + .045*(age-50) +(log(cholesterol - 10)-5.2)*(-2*(sex=='female') + 2*(sex=='male'))).


n <- 1000 # define sample size
set.seed(17) # so can reproduce the results
age <- rnorm(n, 50, 10)
blood.pressure <- rnorm(n, 120, 15)
cholesterol <- rnorm(n, 200, 25)
sex <- factor(sample(c('female','male'), n,TRUE))


#---need explanation for code starting here-----


# Specify population model for log odds that Y=1
L <- .4*(sex=='male') + .045*(age-50) +
(log(cholesterol - 10)-5.2)*(-2*(sex=='female') + 2*(sex=='male'))


# ---end----


# Simulate binary y to have Prob(y=1) = 1/[1+exp(-L)]
y <- ifelse(runif(n) < plogis(L), 1, 0)
ddist <- datadist(age, blood.pressure, cholesterol, sex)
options(datadist='ddist')
f <- lrm(y ~ lsp(age,50)+sex*rcs(cholesterol,4)+blood.pressure)
nom <- nomogram(f, fun=function(x)1/(1+exp(-x)), # or fun=plogis
fun.at=c(.001,.01,.05,seq(.1,.9,by=.1),.95,.99,.999),
funlabel="Risk of Death")
#Instead of fun.at, could have specified fun.lp.at=logit of
... 
Thank you for you expain !
                                                                                truly yours





您想拥有和网易免费邮箱一样强大的软件吗？
	[[alternative HTML version deleted]]

