John Smith wrote:> Dear R-users:
>
> I am trying to use the following code to reproduce the figures on page 140
> of Prof. Frank Harrell's book 'Regression Modeling Strategies':
>
> rm(list=ls())
> options(width=128)
> library(Hmisc)
> library(Design)
>
> getHdata(counties)
> counties$older <- counties$age6574 + counties$age75
> label(counties$older) <- '% age >= 65, 1990'
> counties$pdensity <- log10(counties$pop.density+1)
> label(counties$pdensity) <- 'log 10 of 1992 pop per 1990
miles^2'
>
> dd <- datadist(counties)
> options(datadist='dd')
>
> f <- ols(democrat ~ rcs(pdensity,4) + rcs(pop.change,3) + rcs(older,3) +
> crime + rcs(college,5)
> + rcs(income,4) + rcs(college,5) %ia% rcs(income,4) + rcs(farm,3)
+
> rcs(white,5) +
> rcs(turnout,3), data=counties)
> f
>
> r <- resid(f)
>
> windows(width=10.67, height=6.60)
> par(mfrow=c(3,3))
> par(mar=c(4, 4, 2, 2))
> plot(f, ylim=c(20,70))
>
>
>
> But I have following problems:
> 1): the last two subfigures are different with those from the book;
> 2): I have a error reads:
> Error in if (units == "") g(label) else if (label ==
"") g(units) else if
> (plotmath && :
> missing value where TRUE/FALSE needed
> 3): I think there should be another subfigure on variable
"turnout", but is
> missing in book also
>
> I am using most current version of R, Design and Hmisc.
>
> Thanks
John,
I could reproduce the problem and this indicates a significant bug in
plot.Design in some past version. I am almost certain the current
version is correct because it now produces output that is consistent
with the odds ratio chart. On the bottom row of the figure on p. 140
the voter turnout variable was missing, and as you mentioned the plot
for % white is off. The plot for farm population shows a line that is
too high.
I have fixed the units error and will send you a corrected plot.Design
in a separate e-mail. Thanks for reporting these problems.
Frank>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
--
Frank E Harrell Jr Professor and Chair School of Medicine
Department of Biostatistics Vanderbilt University