[R] Troubles plotting lrm output in Design Library

From: Patrizio Frederic <frederic.patrizio_at_gmail.com>
Date: Thu, 29 May 2008 12:53:38 +0200


Dear R-helpers,
I'm having a problem in using plot.design in Design Library. Tho following example code produce the error:

> 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))
> label(age) <- 'Age' # label is in Hmisc
> label(cholesterol) <- 'Total Cholesterol'
> label(blood.pressure) <- 'Systolic Blood Pressure'
> label(sex) <- 'Sex'
> units(cholesterol) <- 'mg/dl' # uses units.default in Hmisc
> units(blood.pressure) <- 'mmHg'
>
> # 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'))

> # 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')
>
> fit <- lrm(y ~ blood.pressure + sex * (age + rcs(cholesterol,4)),

+                x=TRUE, y=TRUE)

>
> par(mfrow=c(2,2))
> plot(fit) # Plot effects of all 4 predictors
Error in value.chk(at, ix, xseq, if (plot.type == "curves") 100 else 40, :  variable blood.pressure does not have limits defined by datadist

I guess somthing goes wrong with function datadist

> version

              _
platform       i386-pc-mingw32
arch           i386
os             mingw32
system         i386, mingw32
status
major          2
minor          7.0
year           2008
month          04
day            22
svn rev        45424
language       R

version.string R version 2.7.0 (2008-04-22)

thank you in advance,

Patrizio Frederic


| Patrizio Frederic
| Research associate in Statistics,
| Department of Economics,
| University of Modena and Reggio Emilia,
| Via Berengario 51,
| 41100 Modena, Italy
|
| tel:  +39 059 205 6727
| fax:  +39 059 205 6947
| mail: patrizio.frederic_at_unimore.it
+-------------------------------------------------

______________________________________________
R-help_at_r-project.org mailing list
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. Received on Thu 29 May 2008 - 12:19:46 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 29 May 2008 - 15:00:41 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive