#! /usr/bin/R sink(file="/dev/null") # to stop getting announcement text feldt1 <- function(obs.a, n, k, ci = 0.95, null.a = 0, round=2) { #***********************************************************# #* program using methods described in Feldt, Woodruff & *# #* Salih (1987) Applied Psychological Measurement 11(1), *# #* pp. 93-103 to carry out omnibus inferential test of *# #* similarity of alpha values from a single sample *# #***********************************************************# # obs.a is the observed alpha # n is the sample size # k is the number of items in the measure or scale # ci is the width of the confidence interval about obs.a desired if((ci >= 1) || (ci < 0)) return("ci must be between 0 and 1") ci.perc <- 100 * ci# purely for printing as a percentage # null.a is the null model alpha, usually zero # the testing of the observed against the null is a simple F test if(obs.a > null.a) f <- (1 - obs.a)/(1 - null.a) else f <- (1 - null.a)/(1 - obs.a)# allows for testing against a higher null n.den <- (n - 1) * (k - 1) n.num <- n - 1 null.p <- pf(f, n.num, n.den)# set the upper and lower p values for the desired C.I. p1 <- (1 - ci)/2 p2 <- ci + p1# corresponding F values f1 <- qf(p1, n.num, n.den) f2 <- qf(p2, n.num, n.den)# confidence interval lwr <- 1 - (1 - obs.a) * f2 upr <- 1 - (1 - obs.a) * f1 return(c(round(lwr,round),round(upr,round))) } sink() # switch output back to stdout tag(HTML) tag(HEAD) tag(TITLE) cat("Confidence interval of observed Cronbach alpha coefficient") untag(TITLE) untag(HEAD) lf(2) tag(BODY, bgcolor = "lime") lf(2) tag(center) cat("

Confidence interval for an observed Cronbach alpha coefficient

") comments("Let's start with some testing") prob <- 0 n <- as.numeric(scanText(formData$n)) alpha <- as.numeric(scanText(formData$alpha)) k <- as.numeric(scanText(formData$k)) CI <- as.numeric(scanText(formData$CI)) round <- as.numeric(scanText(formData$round)) if ((trunc(n) != n) || (n < 0)) { cat("

n must be a positive integer, go back and try again!

") prob <- 1 } if ((trunc(k) != k) || (alpha < 0)) { cat("

k must be a positive integer, go back and try again!

") prob <- 1 } if ((alpha >= 1) | (alpha < -1)) { cat("

Alpha must be between -1 and 1, (lower is possible but not handled here, go back and try again!

") prob <- 1 } if (trunc(round) != round) { cat("

Rounding value must be an integer, go back and try again!

") prob <- 1 } if ((CI < 60) | (CI > 99.99)) { cat("

CI must be more than 60% and less than 99.99%.

") prob <- 1 } if ((round < 0) | (round > 6)) { cat("

Program only offers rounding to between zero and six decimal places. Go back and try again!

") prob <- 1 } if (prob) { cat("

Go back and try again!

") cat("CGI script written by Chris Evans using David Firth's excellent GGIwithR package. ") linkto("Contact me if something isn't working right ...", "http://www.psyctc.org/cgi-bin/mailto.pl?webmaster") ; br() } lf(2) comments("end of testing") if (!prob) { comments("Got into results section") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("") cat("
") cat("Your input") cat("
") now <- system('date +%Y-%m-%d,%T', intern=TRUE) host <- system("echo $REMOTE_ADDR", intern=TRUE) cat("Request from: ") cat("") cat(host, " at", now,"
") cat("
") cat("n: ") cat("") cat(n) cat("
") cat("k: ") cat("") cat(k) cat("
") cat("Observed alpha: ") cat("") cat(alpha) cat("
") cat("C.I. wanted: ") cat("") cat(CI) cat("%") cat("
") cat("Decimal places wanted: ") cat("") cat(round) cat("
") cat("Results") cat("
") ci <- CI/100 CI.wanted <- feldt1(alpha, n, k, ci = ci, null.a = 0, round = round) # tmp1 <- paste(n,"out of",alpha,"is",round(CI.wanted[1],round)) # cat(tmp1) # br(1) tmp2 <- paste(CI,"% CI is from ",round(CI.wanted[1],round)," to ",round(CI.wanted[2],round),sep="") cat(tmp2) cat("
") cat("
") cat("Explanation and advice for CORE system users and others") cat("
A ",CI,"% CI will embrace the population proportion, i.e. the "true"") cat("proportion in the presumed infinite population from which you took your sample of ",n) cat(" in ",CI,"% of times you take a sample.") cat(" The larger the sample you take, the tighter the CI you'll see but they'll be "right" ") cat(CI,"% of the time, i.e. "wrong": not embrace the population proportion ") wrong <- 100-CI cat(wrong,"% of the time.") cat("

In significance test terms, this means that if you are comparing this with a reference value") cat(" and that reference value is not within that CI, i.e. is either smaller than ") cat(round(CI.wanted[1],round)) cat(" or else is larger than ") cat(round(CI.wanted[2],round)) cat(", you probably have a "significant" difference between your sample and that reference value.") cat("

Statistical significance is often overvalued.") cat(" All that statistical significance is telling you is that a difference ") cat("as large or larger than that was likely to happen less than one time in twenty ") cat("if you were taking samples of size ") cat(n) cat(" from an infinitely large population in which alpha is the reference value.") cat(" The advantage of the CI is that it tells you the precision you'd expect from random") cat(" of samples of size ") cat(n) cat(". What is generally really important in the context of the CI you have here") cat(" is how big the difference between the reference value and your observed value actually is:") cat(" is that difference clinically or managerially interesting to you or your service?

") cat("

If you are using this to compare CORE system parameters you have") cat(" with those from CORE benchmarks or descriptors, always bear in mind differences between") cat(" your or your service's setting and methods that might have contributed to any difference") cat(" you see between your proportion and that in the reference dataset; same if you don't see") cat(" a difference!") cat("

") cat("Technicalities") cat("
") cat("Confidence interval was calculated using Feldt's method which does assume Gaussian distributions.") cat("A good summary reference to Feldt's work is:
") cat("Feldt, Leonard S., Woodruff, David J., & Salih, Fathi A. (1987). Statistical inference for coefficient alpha. Applied Psychological Measurement, 11(1):93-103.

") lf(2) cat("

CGI script written by Chris Evans using David Firth's excellent GGIwithR package. ") linkto("Contact me if something isn't working right ...", "http://www.psyctc.org/cgi-bin/mailto.pl?webmaster") ; br() lf() cat("

") cat("Output produced at ", date()) cat("

") lf() cat("
") } untag(BODY) untag(HTML) lf() sink(paste("/home/xychris0/R/CGIwithR-log/Feldt1.R.",as.character(now),sep="")) cat("program = Feldt1.R ; host = ",host, "; ", now, "; n = ",n,"; alpha = ",alpha,"; CI = ",CI,"; round = ",round,"\n") sink()