Hi David,

As suggested, here is some example code adapted from the example of the
nomogram() from the rms package.  You'll notice that variable labels are
not being applied to main effects or interaction terms.

Leonardo

rm(list = ls())
# Import libraries
require(Hmisc)
require(rms)

set.seed(12345)
n <- 1000 # define sample size
age <- rnorm(n, 0, 10)
sbp <- rnorm(n, 120, 15)
sex <- factor(sample(c(0,1), n, TRUE), levels=c(0,1),
labels=c('female','male'))
# Specify population model for log odds that Y=1
L <- 0.5*(sex=="male") + 0.01*age + 0.12*sbp + 0.02*sbp*age + rnorm(n, 0,
10)
# Simulate binary y to have Prob(y=1) = 1/[1+exp(-L)]
y <- ifelse(runif(n) < plogis(L), 1, 0)

# Create a dataframe and apply nice labels to each variable.
mydata <- data.frame(age, sbp, sex, y)
var.labels <- c(age = "Patient Age - 50 years",
                sbp = "Systolic blood pressure",
                sex = "Sex",
                y = "Outcome")
label(mydata) = lapply(names(var.labels),
                       function(x) label(mydata[,x]) <- var.labels[x])
label(mydata) # show the labels.

# Fit a model
ddist <- datadist(mydata)
options(datadist="ddist")
f <- rms::lrm(y ~ age*sbp + sex)
f
f$coefficients

# Create a nomogram.
nom <- nomogram(f, fun=plogis, lp=F, nint=10, maxscale=100,
                interact = list( sbp=c(100,140,180) ),
                fun.at=c(.01,.05,seq(.1,.9,by=.1),.95,.99),
                funlabel="Risk of Death", vnames="labels")
plot(nom)

# end
options(datadist=NULL)


On Fri, Aug 26, 2016 at 10:35 PM, David Winsemius <dwinsem...@comcast.net>
wrote:

>
> > On Aug 26, 2016, at 11:53 AM, Leonardo Guizzetti <
> leonardo.guizze...@gmail.com> wrote:
> >
> > Good afternoon,
> >
> > I have tried searching and have hit a wall with my own trial and error. I
> > have been able to use "nice" labels for non-interacted variables by
> setting
> > them using Newlabels(), but I am unable to do so for the interaction
> terms
> > following a fit.
> >
> > Can you please offer a suggestion?
>
> My suggestion is that you post a minimal example.
>
> --
> David.
> >
> > Kind regards,
> > Leonardo
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> David Winsemius
> Alameda, CA, USA
>
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to