Hi there, I wonder if anyone can help me. I'm trying to use bargraph.CI in the Sciplot package when there is a missing combination of the factor levels. Unfortunately the standard errors on the plot do not appear to be correct. Consider an analysis consisting of two factors A and B. When all factor level combinations are present all appears fine: library(sciplot) #all data response<-c(32,54,32,65,34,65,65,45,54,23,43,23,76,87,65,45) factorA<-c("A","A","A","A","A","A","A","A","B","B","B","B","B","B","B","B") factorB<-c("a","a","a","a","b","b","b","b","a","a","a","a","b","b","b","b") data<-data.frame(response,factorA,factorB) bargraph.CI(x.factor = data$factorB,data$response, group=data$factorA, legend=TRUE) but when I remove a combination of the two factors the error whiskers appear to be on the wrong bars: #excluding one combination response<-c(34,65,65,45,54,23,43,23,76,87,65,45) factorA<-c("A","A","A","A","B","B","B","B","B","B","B","B") factorB<-c("b","b","b","b","a","a","a","a","b","b","b","b") data<-data.frame(response,factorA,factorB) bargraph.CI(x.factor = data$factorB,data$response, group=data$factorA, legend=TRUE) I had a look at the ci.fun options but with no success. Thanks in advance for any ideas Simon -- View this message in context: http://www.nabble.com/Problem-with-bargraph.CI-in-Sciplot-package-tp22995415p22995415.html Sent from the R help mailing list archive at Nabble.com.
Metconnection <simontbate <at> hotmail.co.uk> writes:> > > Hi there, > I wonder if anyone can help me. I'm trying to use bargraph.CI in the Sciplot > package when there is a missing combination of the factor levels. > Unfortunately the standard errors on the plot do not appear to be correct. >...> but when I remove a combination of the two factors the error whiskers appear > to be on the wrong bars: > > #excluding one combination > response<-c(34,65,65,45,54,23,43,23,76,87,65,45) > factorA<-c("A","A","A","A","B","B","B","B","B","B","B","B") > factorB<-c("b","b","b","b","a","a","a","a","b","b","b","b") > data<-data.frame(response,factorA,factorB) > bargraph.CI(x.factor = data$factorB,data$response, group=data$factorA, > legend=TRUE) >This is a bug you should report to the author. Standard R-wisdom would be not to use this type of plot. But I know that big bosses love it, because it shows more ink. One day, even Deepayan gave up and posted: http://markmail.org/message/7lxmnvimcgvkulmw Dieter
On Fri, 2009-04-10 at 15:07 -0700, Metconnection wrote:> Hi there, > I wonder if anyone can help me. I'm trying to use bargraph.CI in the Sciplot > package when there is a missing combination of the factor levels. > Unfortunately the standard errors on the plot do not appear to be correct. > > Consider an analysis consisting of two factors A and B. When all factor > level combinations are present all appears fine: > > library(sciplot) > > #all data > response<-c(32,54,32,65,34,65,65,45,54,23,43,23,76,87,65,45) > factorA<-c("A","A","A","A","A","A","A","A","B","B","B","B","B","B","B","B") > factorB<-c("a","a","a","a","b","b","b","b","a","a","a","a","b","b","b","b") > data<-data.frame(response,factorA,factorB) > bargraph.CI(x.factor = data$factorB,data$response, group=data$factorA, > legend=TRUE) > > > > but when I remove a combination of the two factors the error whiskers appear > to be on the wrong bars: > > > #excluding one combination > response<-c(34,65,65,45,54,23,43,23,76,87,65,45) > factorA<-c("A","A","A","A","B","B","B","B","B","B","B","B") > factorB<-c("b","b","b","b","a","a","a","a","b","b","b","b") > data<-data.frame(response,factorA,factorB) > bargraph.CI(x.factor = data$factorB,data$response, group=data$factorA, > legend=TRUE) > > > I had a look at the ci.fun options but with no success. > > Thanks in advance for any ideas > SimonHi Simon, bargraph.CI was intended for factorial designs and it doesn't work well with missing factor combinations. I'll take a look at changing this, but for now, a quick fix is to add the missing combination with an NA value for the response. Eg., change the data in your second example to: response<-c(34,65,65,45,54,23,43,23,76,87,65,45,NA) factorA<-c("A","A","A","A","B","B","B","B","B","B","B","B","A") factorB<-c("b","b","b","b","a","a","a","a","b","b","b","b","a") -- http://mutualism.williams.edu
Reasonably Related Threads
- error in bargraph.CI {sciplot}
- testing two-factor anova effects using model comparison approach with lm() and anova()
- bargraph.ci - CI and color question.
- How to generate a new factor variable by two other factor variables
- using par funtions in bargraph.CI()