#! /usr/bin/R n <- as.numeric(formData$n)[1] sig <- as.numeric(formData$se)[1] mu <- as.numeric(formData$mean)[1] alpha <- as.numeric(formData$alph)[1] alpha100 <- paste(alpha*100,"%",sep="") tag(HTML) tag(HEAD) tag(TITLE) cat(n,alpha100,"Confidence Intervals") untag(TITLE) untag(HEAD) lf(2) tag(BODY) lf(2) tag(h1) cat("Graph of",n,alpha100,"Confidence Intervals") untag(h1) lf(2) #cat(mu,sig); lf(1) lb <- floor(mu - 3.5*sig) ub <- ceiling(mu + 3.5*sig) #cat(lb,ub); lf(1) XX <- rnorm(n,mu,sig) aa <- (1-alpha)/2 #cat(aa); lf(1) webPNG("intEst.png") tryCatch({ plot(c(lb,ub),c(0,n+1),ylab="Trial",type="n", xlab="Data value", sub=paste("Mean =",mu,"; Standard Error =",sig)) abline(v=mu,lty=as.numeric(formData$lty)) text(mu+.2*sig,0.015,expression(mu)) for (i in 1:n) { X <- XX[i] Z <- (X-mu)/sig pch <- floor(abs(Z))+1 # This will give different plotting symbols # depending on Z score pch <- ifelse(pch>2,5,pch) points(X,i,pch=pch) segments(X+sig*qnorm(aa),i,X+sig*qnorm(1-aa),i, col=formData$col) } legend("topleft",c("Within 1 SE","Between 1 and 2 SEs","Two or more SEs"), pch=c(1,2,5)) },error = function(e){cat(conditionMessage(e)); lf(1)}) img(src = "intEst.png") ; br(2) lf(2) cat("About",alpha100," of the intervals should overlap the vertical line") lf(2) cat("You can copy and paste the histogram picture to use in other reports.") lf(2) cat("To try other data, or other values for the parameters," cat("hit the back button on your browser.") lf() cat("The author is ") mailto("Russell Almond", "ralmond@admin.fsu.edu") lf() tag(p) cat("Output produced at ", date()) untag(p) lf() untag(BODY) lf() untag(HTML) lf()