Learn R Programming

ptest (version 1.0-8)

ptestg: Test short time series for periodicity based on periodograms

Description

This function is used to test the existence of the periodicity for a short time series (length

Usage

ptestg(z, method = c("Fisher", "robust", "extended", "extendedRobust", "FisherRSR"), multiple = FALSE)

Arguments

z
A series or a matrix containg series as columns
method
The statistical test to be used. See details for more information.
multiple
Indicating whether z contains multiple series.

Value

Object of class "Htest" produced.An object of class "Htest" is a list containing the following components:

Details

The null hypothesis is set as no peridicities, H0: f=0. Discriptions of different test statistics (methods) are as follow:

Fisher: The Fisher's g test statistic. The p-value is computed directly from the exact distribution.

robust: The robust g test proprosed in Ahdesmaki et al. (2005), where the p-value is computed by the response surface regression method.

extended: The extended Fisher's g test statistic, which extend the Fisher's g test by enlarging the searching region of the frequency from the fourier frequencies to be $En = {j/101 | j=1,\dots,50 and j/101 \ge 1/n}$. The p-value is computed by the response surface regression method.

extendedRobust: Extend the frequency searching region of the robust $En = {j/101 | j=1,\dots,50 and j/101 \ge 1/n}$. The p-value is computed by the response surface regression method.

FisherRSR: Only for experimental purposes, the Fisher;s g test with p-value computed form the response surface regression method.

References

Fisher, R.A. (1929). Tests of significance in harmonic analysis. Proc. Roy. Soc. A, 125, 54-59.

Ahdesmaki, M., Lahdesmaki, H., Pearson, R., Huttunen, H., and Yli-Harja O.(2005). BMC Bioinformatics 6:117. http://www.biomedcentral.com/1471-2105/6/117.

MacKinnon, James (2001) : Computing numerical distribution functions in econometrics, Queen's Economics Department Working Paper, No. 1037.

See Also

ptestReg

Examples

Run this code
# Simulate the harmonic regression model with standard Gaussian error terms
set.seed(193)
## Non-Fourier frequency
z <- simHReg(n = 14, f=2/10, A = 2, B = 1, model="Gaussian",sig=1) 
ptestg(z,method="Fisher")
ptestg(z,method="robust")
ptestg(z,method="extended")
ptestg(z,method="extendedRobust")
ptestg(z,method="FisherRSR")

# Performe tests on the alpha factor experiment
data(alpha)
## Eliminate genes with missing observations
alpha.nonNA <- alpha[complete.cases(alpha),]
## Using the multiple option to do the test for all the genes
## Transpose the data set so that each column stands for a gene
alpha.nonNA <- t(alpha.nonNA)
result <- ptestg(alpha.nonNA, method = "extended",multiple=TRUE) 
str(result)              

                                                                        
# The movtivating example: gene ORF06806 in Cc
data(Cc)
x <- Cc[which(rownames(Cc)=="ORF06806"),]
plot(1:length(x),x,type="b", main="ORF06806",
     xlab="time",ylab="Gene expression")
ptestg(x,method="Fisher") #Fail to detect the periodicity
ptestg(x,method="robust") 
ptestg(x,method="extended") 

Run the code above in your browser using DataLab