Only the last appears, because the function returns only the last, which then gets printed. The answer to your question depends on whether you want to see the results or store them. To see them, try the following:

root.print <- function(var)
{
#---Phillips-Perron
print(PP.test(var, lshort = TRUE) )
print(PP.test(var, lshort = FALSE) )

#---Augmented Dickey-Fuller print(adf.test(var, alternative = "stationary", k =
trunc((length(var)-1)^(1/3))))


#---KPSS
print(kpss.test(var, null = "Level", lshort = TRUE))
print(kpss.test(var, null = "Trend", lshort = FALSE))
}

To store the results, try:

root.store <- function(var)
{
#---Phillips-Perron
t1 <- PP.test(var, lshort = TRUE) t2 <- PP.test(var, lshort = FALSE)


#---Augmented Dickey-Fuller t3 <- adf.test(var, alternative = "stationary", k =
trunc((length(var)-1)^(1/3)))


#---KPSS
t4 <- kpss.test(var, null = "Level", lshort = TRUE)
t5 <- kpss.test(var, null = "Trend", lshort = FALSE)
list(PP.testT=t1, PP.testF=t2, adf.test=t3, kpss.testT=t4, kpss.testF=t5)
}

hope this helps. spencer graves

bogdan romocea wrote:

Dear R users,

I have a function (below) which encompasses several tests.
However, when I run it, only the output of the last test is
displayed. How can I ensure that the function root(var)
will run and display the output from all tests, and not
just the last one?

Thank you,
b.

root <- function(var)
{
#---Phillips-Perron
PP.test(var, lshort = TRUE) PP.test(var, lshort = FALSE)


#---Augmented Dickey-Fuller adf.test(var, alternative = "stationary", k =
trunc((length(var)-1)^(1/3)))


#---KPSS
kpss.test(var, null = "Level", lshort = TRUE)
kpss.test(var, null = "Trend", lshort = FALSE)
}

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html



-- Spencer Graves, PhD, Senior Development Engineer O: (408)938-4420; mobile: (408)655-4567

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to