dd <- read.table("Caffeine.txt",header=T) attach(dd) rr <- DitheredDotPlot(dose,fingertaps,3) # siehe unten par(mai=c(0.5,0.5,0.05,0.05)) plot(rr$X, rr$Y, pch=19,cex.axis=1.2,xaxp=c(0,200,2), xlab="", ylab="",xlim=c(-10,210)) ll <- lm(fingertaps ~ dose) a <- ll$coefficients[1] # intercept b <- ll$coefficients[2] # slope xx <- c(-10,210) yy <- a + b*xx lines(xx,yy) DitheredDotPlot <- function(X,Y,wd=1) { tmp <- sort(X,index.return=T) Xd <- tmp$x Yd <- Y[tmp$ix] G <- c(0, which(Xd[1:(length(X)-1)] < Xd[2:length(X)]), length(X)) for (i in 2:length(G)) { tmp <- (G[i-1]+1):G[i] Yd[tmp] <- sort(Yd[tmp]) rr <- lm(tmp ~ as.factor(Yd[tmp])) Xd[tmp] <- Xd[tmp] + wd*rr$residuals } return(list(X=Xd,Y=Yd)) }