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

Peter Dalgaard pd@|gd @end|ng |rom gm@||@com
Wed Nov 12 13:49:57 CET 2025


There's a worked example of the procedure in Altman: Practical Statistics for Medical Research, also featured in help(ISwR::caesarean). 

(I have forgotten the origin of example(prop.trend.test), though. If I ever knew it. Apparently it is the same as in help(prop.test): Fleiss(1981), p.139, but I don't have that edition to hand and I don't see it in Fleiss(1973).)

-pd


> On 12 Nov 2025, at 11.55, Michael Dewey <lists using dewey.myzen.co.uk> wrote:
> 
> 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
> 
> ______________________________________________
> 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.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd.mes using cbs.dk  Priv: PDalgd using gmail.com



More information about the R-help mailing list