[R] package stats / prop.trend.test function

Michael Dewey ||@t@ @end|ng |rom dewey@myzen@co@uk
Wed Nov 12 11:55:22 CET 2025


Dear Paulo

You did realise that if you type prop.trend.test you get

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")
}
<bytecode: 0x0000021d81d4c850>
<environment: namespace:stats>

Does that help?

Michael

On 11/11/2025 18:27, Paulo Barata wrote:
> To the R-Help list,
> 
> About the prop.trend.test function, in the package stats.
> 
> What calculations exactly does that function perform? What test is 
> actually carried out? May I have some reference for the calculations 
> performed by that function?
> 
> I would like to suggest that some references (one or more) be included 
> in the Help file for the function.
> 
> Thank you very much.
> 
> Paulo Barata
> 
> Rio de Janeiro - Brazil
> 
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide https://www.R-project.org/posting- 
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Michael Dewey



More information about the R-help mailing list