s-news
[Top] [All Lists]

Labels wrong with lrm

To: "S-NEWS (E-post)" <s-news@lists.biostat.wustl.edu>
Subject: Labels wrong with lrm
From: Jan Brogger <jan.brogger@med.uib.no>
Date: Fri, 27 Jul 2001 14:54:10 +0200
Reply-to: "jan.brogger@med.uib.no" <jan.brogger@med.uib.no>
I get funny behaviour from lrm when using transformations that require a 
parameter, and the parameter is a variable. It only happens when there are 
other variables in the model. The transformation must be the last term in 
the formula, or some labels will be wrong. For example, if the correct 
labels are "age" "age^2" and "smok", the labels will be "age", "age^2" and 
"kx" where "kx" is actually the parameter for the transformation.

I have tried including the variable that contains the parameter for the 
transformation with datadist, but it doesn't help. Also tried reinstalling 
newest Hmisc, Design and starting new project directory. Platform: S+2000 
Win98. It happens to both rcs and pol. With glm, everything is OK. The 
value of coefficients are the same.

It isn't a major issue, but it might puzzle some and I thought I'd let you 
know. Solutions are: specify the parameters transformations directly, not 
in variables, or keep your transformations last in the formula. Any better 
solutions ? It'd be nice to be able to keep knot locations in a variable, 
so you can change it only one place in your code.

This code reproduces the problem:
library(Hmisc,T)
library(Design,T)
age <- rnorm(500,41.5,12) #age
smok <- sample(0:2,500,rep=T) #smoking habit
asthma <- sample(0:1,500,rep=T)  #asthma
mydat <- data.frame(age,smok,asthma)
dd <- datadist(mydat)
options(datadist="dd")
kx <- 2

#this model gives the wrong labels
lrm(asthma~pol(age,kx)+smok,data=mydat) 
#this model gives the right label
lrm(asthma~smok+pol(age,kx),data=mydat)

#If you don't use a variable, but a value, then everything is ok
lrm(asthma~smok+pol(age,2),data=mydat)
lrm(asthma~pol(age,2)+smok,data=mydat)
#If you only have one term, then everything is OK
lrm(asthma~pol(age,2),data=mydat)
#It doesn't happen with GLM:
glm(asthma~pol(age,2)+smok,data=mydat,family=binomial)
#but it does with rcs:
kx <- c(15,40,70)
lrm(asthma~rcs(age,kx)+smok,data=mydat) 
lrm(asthma~smok+rcs(age,kx),data=mydat) 


Jan Brogger,
University of Bergen, Norway

<Prev in Thread] Current Thread [Next in Thread>