[R] R: plot partial effects

Sebastian Heyneman @eb@@t|@n@h@we||@ @end|ng |rom gm@||@com
Tue Jan 22 03:56:17 CET 2019


Dear All:


I tried to replicate a case study described by Prof. Harrell in Chapter 7 of

his Regression Modeling Strategies book, but failed on using plot to

reproduce partial effects diagram in figure 7.9,  Following is the code:


rm(list=ls())

library(Hmisc)


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

plot(f, ylim = c(20,70))


and the error message reads as:


Error in match.arg(type) :
  'arg' should be one of “ordinary”, “score”, “dfbeta”, “dfbetas”,
“dffit”, “dffits”, “hat”, “hscore”



Does anyone have a clue?


Regards,

Sebastian

	[[alternative HTML version deleted]]



More information about the R-help mailing list