[R] trend test for frequencies

David Winsemius dwinsemius at comcast.net
Mon Mar 1 01:04:18 CET 2010


On Feb 28, 2010, at 5:33 PM, Martin Batholdy wrote:

> Hi,
>
> which test do I have to use if I want to test if the following data  
> follow a monotone trend;
>
> min	5min	10min	20min	30min
> 5		20		55		70		90
>
> ... where the dependent variable contains frequencies.

It is not clear what you mean by "frequencies". Do you mean counts?  
I's also unclear what your data situation is and what sort of  
independence assumptions might be met (or not). Here's a possible  
computational run that might have a plausible error structure for  
count data and form the basis for a "linear trend test" but whether it  
can be applied to your experiment is not assured. In particular the  
independence assumption seems questionable if the counts are arising  
from the same experimental subjects. You may want to calculate the  
differences if these are cumulative counts:

 > dta <-data.frame(time=c(1,5,10,20,30), counts=c(5,20,55,70, 90))

 > glm(counts~time, data=dta, family="poisson")

Call:  glm(formula = counts ~ time, family = "poisson", data = dta)

Coefficients:
(Intercept)         time
     2.92950      0.05704

Degrees of Freedom: 4 Total (i.e. Null);  3 Residual
Null Deviance:	    123.3
Residual Deviance: 32.91 	AIC: 63.51

If these are cumulative counts, the "monotone trend" may not be as  
solidly supported:

 > dta$diffs <-c(dta$counts[1], diff(dta$counts))
 > dta
   time counts diffs
1    1      5     5
2    5     20    15
3   10     55    35
4   20     70    15
5   30     90    20
 > mod0 <- glm(diffs~1, data=dta, family="poisson")
 > mod <- glm(diffs~time, data=dta, family="poisson")
 > anova(mod,mod0)
Analysis of Deviance Table

Model 1: diffs ~ time
Model 2: diffs ~ 1
   Resid. Df Resid. Dev Df Deviance
1         3     25.034
2         4     27.014 -1  -1.9799




-- 
David Winsemius, MD, MPH



More information about the R-help mailing list