Skip to content

TsayData

1 message · Diethelm Wuertz

#
Unfortunately, the Tsay data sets got lost in the  fSeries package.

They are downloadable from the authors web site at

http://www.gsb.uchicago.edu/fac/ruey.tsay/teaching/fts/

You can also use the follwing (untested) function to download
the data sets from the web site mentioned above.

Diethelm Wuertz

tsaySeries =
function(query = "d-ibmln", file = "tempfile",
source = "http://www.gsb.uchicago.edu/fac/ruey.tsay/teaching/fts/",
save = FALSE, sepCSV = ";", try = TRUE, ...)
{   # A function implemented by Diethelm Wuertz

    # Description:
    #   Downloads *.dat data sets from R Tsay's textbook
   
    # Value:
    #   A data frame.
       
    # Examples:
    #   tsaySeries(query = "d-ibmln")   1-column
    #   tsaySeries(query = "d-vwew")    3-column

    # FUNCTION:
    
    # Download:
    if (try) {
        # Try for Internet Connection:
        z = try(tsaySeries(query = query, file = file, source = source,
            save = save, try = FALSE))
        if (class(z) == "try-error" || class(z) == "Error") {
            return("No Internet Access")
        } else {
            return(z)
        }
    } else {
        # File name:
        queryFile = paste(query, ".dat", sep = "")
       
        # For S-Plus Compatibility:
        if (class(version) != "Sversion") {
            # R:
            method = NULL
        } else {
            # SPlus
            method = "wget"
        }
   
        # Download and temporarily store:
        download.file(url = paste(source, queryFile, sep = ""),
            destfile = file, method = method)
       
        # Scan the file and transform into data frame:
        ans = read.table(file, ...)
       
        # Save download ?
        if (save) {
            write.table(z, file, quote = FALSE, col.names = FALSE,
                sep = sepCSV)
        } else {
            unlink(file)
        }
       
        # Return Value:
        return(ans)
    }
   
    # Return Value:
    invisible()
}
SUMANTA BASAK wrote: