Colleagues, The code for prop.trend.test is given by:
function (x, n, score = seq_along(x)) { method <- "Chi-squared Test for Trend in Proportions" dname <- paste(deparse1(substitute(x)), "out of", deparse1(substitute(n)), ",\n using scores:", paste(score, collapse = " ")) x <- as.vector(x) n <- as.vector(n) p <- sum(x)/sum(n) w <- n/p/(1 - p) a <- anova(lm(freq ~ score, data = list(freq = x/n, score = as.vector(score)), weights = w)) chisq <- c(`X-squared` = a["score", "Sum Sq"]) structure(list(statistic = chisq, parameter = c(df = 1), p.value = pchisq(as.numeric(chisq), 1, lower.tail = FALSE), method = method, data.name = dname), class = "htest") } It seems to me that the direction of the trend is found using the weighted regression lm(freq ~ score, data = list(freq = x/n, score = as.vector(score)), weights = w)) Am I on the right track here? Thomas Subia ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.