# R/spsm.R In punitroots: Unit Roots in Panels of Time Series

```spsm <- function(pCADFtest.results, alpha = 0.05)
{
## Sequential Panel Selection Method
##
## alpha:      	significance level

## Initialize some values
N <- nrow(pCADFtest.results\$individual.tests) # N: number of time series
K.rej <- NULL                          # K.rej: variables identified as I(0)

## Define the full set of time series
S <- 1:N

## continue only if the panel test rejects
{
## identify the minimum p-value of univariate tests (u.rej)
r <- which.min(pvalues)
K.rej <- r
pvalues[r] <- 9999
## S1: all the series except the one under test
S1 <- S[-r]
rej <- TRUE
while((length(S1) > 0)&(rej == TRUE))
{
sub.p.values <- pvalues[S1]
if (pCADFtest.results\$corr == FALSE)
{
# Perform Choi's test (inverse normal combination)
Z    <- sum(qnorm(sub.p.values))/sqrt(length(sub.p.values))   # simple combination statistic
pval <- pnorm(Z)                      # pvalue of Choi's test
}
else
{
if (length(S1) > 1)
{
# Perform Hartung's adjustment
hart <- Hartung(sub.p.values)       # Hartung's correction
Z    <- hart\$statistic
pval <- hart\$p.value
}
else
{
pval <- sub.p.values
}
}
rej <- (pval < alpha)
if (rej == TRUE)
{
r <- c(r, which.min(pvalues))
K.rej <- r
pvalues[r] <- 9999
S1 <- S[-r]
}
}
}
return(K.rej)
}
```

## Try the punitroots package in your browser

Any scripts or data that you put into this service are public.

punitroots documentation built on May 2, 2019, 5:16 p.m.