[R] possible bug in xYplot and smean.cl.normal

Harry Athanassiou hasentmail at gmail.com
Sat Apr 21 02:30:17 CEST 2007


I'm using R (2.4.1) and Hmisc (3.3-1), and I'd like to plot confidence
intervals using xYplot and smean.cl.normal (or smean.cl.boot) from Hmisc.
You can do that using the summarize() to produce a new data.frame and then
plot with xYplot, or by specifying method=smean.cl.normal in the xYplot.
Both produce very similar graphs in all trivial examples I've tried, but not
in the attached dataset, where the "method=smean.cl.normal in the xYplot"
produces much smaller Cis! This happens only with smean.cl.boot and
smean.cl.normal, but not with quantile!

Please help

#######
##
## plot CIs : compare summarize and xYplot(method= fun)
##
 
# this is a part of a larger set, but the issue is the same
dat.fss <- read.csv("JMF2_141-dbdemo-FSS-FSS.csv")

summary(dat.fss$Colony_Cnt)
# fix factors
dat.fss$WellCol	<- ordered(dat.fss$WellCol)

# define common scale for the y
ylim1 <- c(0,600)

require(Hmisc)


#
# smean.cl.normal
#

conf.int.1 <- 0.95
attach(dat.fss)
ci <- summarize(Colony_Cnt, llist(WellRow, WellCol, WellName, Treatment,
Scan), smean.cl.normal, conf.int=conf.int.1, na.rm=T)
detach("dat.fss")


# using summarize
xYplot(Cbind(Colony_Cnt, Lower, Upper) ~ Scan | WellCol * WellRow, groups=
Treatment, data= ci,
	cex=0.1, lwd=2, lty.bands=rep("solid", 2), col.bands=rep("black",
2), lwd.bands=rep(1,2),
	method="bands", type="l", ylim= ylim1, na.rm=T
	)	
# using method=
xYplot(Colony_Cnt ~ Scan | WellCol * WellRow , groups= Treatment, data=
dat.fss,
	cex=0.1, lwd=2, lty.bands=rep("solid", 2), col.bands=rep("black",
2), lwd.bands=rep(1,2),
	method= smean.cl.normal, methodArgs= list(conf.int=conf.int.1), 
	type="l", ylim= ylim1, na.rm=T
	)	

# VERY different CIs!!!!


#
# quantile
#

attach(dat.fss)
probs1 <- c(0.5, 0.25, 0.75)
ci <- summarize(Colony_Cnt, llist(WellRow, WellCol, WellName, Treatment,
Scan), quantile, probs= probs1, na.rm=T)
detach("dat.fss")
n1 <- length(colnames(ci))
colnames(ci)[(n1-1):n1] <- c("Lower", "Upper") # rename cols to match

# using summarize
xYplot(Cbind(Colony_Cnt, Lower, Upper) ~ Scan | WellCol * WellRow, groups=
Treatment, data= ci,
	cex=0.1, lwd=2, lty.bands=rep("solid", 2), col.bands=rep("black",
2), lwd.bands=rep(1,2),
	method="bands", type="l", ylim= ylim1, na.rm=T
	)	
# using method=
xYplot(Colony_Cnt ~ Scan | WellCol * WellRow , groups= Treatment, data=
dat.fss,
	cex=0.1, lwd=2, lty.bands=rep("solid", 2), col.bands=rep("black",
2), lwd.bands=rep(1,2),
	method= "quantile", methodArgs= list(probs= probs1), 
	type="l", ylim= ylim1, na.rm=T
	)


# VERY close with quantile


#######


More information about the R-help mailing list