Using the Hmisc plsmo Function for Plotting Nonparametric loess Trend lines

R Clinic 23Oct08

The following examples use a new Titanic passenger and group survival dataset soon to be put on our Datasets page.

load('/home/harrelfe/data/teaching/titanic2008.rda')
xless(contents(titanic2008))
attach(titanic2008)
plsmo(age, survived)
plsmo(age, survived, datadensity=TRUE)
plsmo(age, survived, group=sex, datadensity=TRUE)
table(class.dept)
class.dept
  1st Class   2nd Class   3rd Class  A la Carte        Deck      Engine
        324         285         708          69          66         325
Victualling
        431
plsmo(age, survived, group=class.dept, datadensity=TRUE)
s <- class.dept %in% levels(class.dept)[1:3]
with(subset(titanic2008,s),plsmo(age, survived, group=interaction(sex,factor(class.dept)),
 datadensity=TRUE))
plsmo(age, survived, group=class.dept, datadensity=TRUE)
plsmo(age, survived, group=class.dept, datadensity=TRUE,trim=0)
with(subset(titanic2008,s),plsmo(age, survived, group=interaction(sex,factor(class.dept)),
 datadensity=TRUE, trim=0))
w <- summary(survived ~ age + sex + class.dept)
plot(w)
plot(w, cex=2)
plot(w, cex=2, cex.labels=1)
with(subset(titanic2008,s),plsmo(age, survived, group=interaction(sex,factor(class.dept)),
 datadensity=TRUE, trim=0))
Ecdf(age)
Ecdf(age, q=c(1:3)/4)
with(subset(titanic2008,s),plsmo(age, survived, group=interaction(sex,factor(class.dept)),
 datadensity=TRUE, trim=0))
Topic revision: r1 - 26 Oct 2008 - 10:37:42 - FrankHarrell
 
Register | Log In
Copyright © 2009 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback