r - constructing an error bar with compositional data -
i have problem , there me.
i have data set compositional data, each weekday of 160 weeks ratio of cars measured. sum of 3 ratios sum 1. there 3 types of cars in research.
my task construct mean , 'error bar'. used following lines of code in r:
day = rep(c("sunday","monday","tuesday","wednesday","thursday","friday", "saterday"),3) cars = c(rep("nissan",7),rep("toyota",7),rep("bmw",7)) y <- colmeans(datadag,na.rm=true) delta <- apply(datadag,2,sd,na.rm=true) df=data.frame(day,cars,y,delta) p<-ggplot(df,aes(x=day,y=y,group=device,color=device))+ geom_point() + geom_errorbar(aes(ymin=y-delta,ymax=y+delta),width=.6) print(p)
the code above give following plot:
the problem face error bounds exceeds 0 , 1 not possible because of compositional data. can tell me did wrong?
your problem statistical, not r. assuming standard deviation "know" data cannot negative. consider following.
foo <- c(0,0,1,1000) mean(foo) - sd(foo) [1] -249.5836
i not sure if same problem can arise standard error suspect can...
Comments
Post a Comment