Example #1
0
def load():
    """
    Loads the Grunfeld data and returns a Dataset class.

    Returns
    -------
    Dataset instance:
        See DATASET_PROPOSAL.txt for more information.

    Notes
    -----
    raw_data has the firm variable expanded to dummy variables for each
    firm (ie., there is no reference dummy)
    """
    filepath = dirname(abspath(__file__))
    data = recfromtxt(open(filepath + '/grunfeld.csv', 'rb'),
                      delimiter=",",
                      names=True,
                      dtype="f8,f8,f8,a17,f8")
    names = list(data.dtype.names)
    endog = array(data[names[0]], dtype=float)
    endog_name = names[0]
    exog = data[list(names[1:])]
    exog_name = list(names[1:])
    dataset = Dataset(data=data,
                      names=names,
                      endog=endog,
                      exog=exog,
                      endog_name=endog_name,
                      exog_name=exog_name)
    raw_data = categorical(data, col='firm', drop=True)
    dataset.raw_data = raw_data
    return dataset
Example #2
0
def load():
    """
    Loads the Grunfeld data and returns a Dataset class.

    Returns
    -------
    Dataset instance:
        See DATASET_PROPOSAL.txt for more information.

    Notes
    -----
    raw_data has the firm variable expanded to dummy variables for each
    firm (ie., there is no reference dummy)
    """
    filepath = dirname(abspath(__file__))
    data = recfromtxt(open(filepath + '/grunfeld.csv','rb'), delimiter=",",
            names=True, dtype="f8,f8,f8,a17,f8")
    names = list(data.dtype.names)
    endog = array(data[names[0]], dtype=float)
    endog_name = names[0]
    exog = data[list(names[1:])]
    exog_name = list(names[1:])
    dataset = Dataset(data=data, names=names, endog=endog, exog=exog,
            endog_name=endog_name, exog_name=exog_name)
    raw_data = categorical(data, col='firm', drop=True)
    dataset.raw_data = raw_data
    return dataset
Example #3
0
def load():
    """
    Load the strikes data and return a Dataset class instance.

    Returns
    -------
    Dataset instance:
        See DATASET_PROPOSAL.txt for more information.
    """
    filepath = dirname(abspath(__file__))
    ##### EDIT THE FOLLOWING TO POINT TO DatasetName.csv #####
    data = recfromtxt(open(filepath + '/strikes.csv', 'rb'),
                      delimiter=",",
                      names=True,
                      dtype=float)
    names = list(data.dtype.names)
    ##### SET THE INDEX #####
    endog = array(data[names[0]], dtype=float)
    endog_name = names[0]
    ##### SET THE INDEX #####
    exog = column_stack(data[i] for i in names[1:]).astype(float)
    exog_name = names[1:]
    dataset = Dataset(data=data,
                      names=names,
                      endog=endog,
                      exog=exog,
                      endog_name=endog_name,
                      exog_name=exog_name)
    return dataset
Example #4
0
def load():
    """
    Load the Longley data and return a Dataset class.

    Returns
    -------
    Dataset instance
        See DATASET_PROPOSAL.txt for more information.
    """
    filepath = dirname(abspath(__file__))
    data = recfromtxt(open(filepath + '/longley.csv', "rb"),
                      delimiter=",",
                      names=True,
                      dtype=float,
                      usecols=(1, 2, 3, 4, 5, 6, 7))
    names = list(data.dtype.names)
    endog = array(data[names[0]], dtype=float)
    endog_name = names[0]
    exog = column_stack(data[i] for i in names[1:]).astype(float)
    exog_name = names[1:]
    dataset = Dataset(data=data,
                      names=names,
                      endog=endog,
                      exog=exog,
                      endog_name=endog_name,
                      exog_name=exog_name)
    return dataset
Example #5
0
def load():
    """Load the credit card data and returns a Dataset class.

    Returns
    -------
    Dataset instance:
        See DATASET_PROPOSAL.txt for more information.
    """
    filepath = dirname(abspath(__file__))
    data = recfromtxt(open(filepath + '/ccard.csv', 'rb'),
                      delimiter=",",
                      names=True,
                      dtype=float)
    names = list(data.dtype.names)
    endog = array(data[names[0]], dtype=float)
    endog_name = names[0]
    exog = column_stack(data[i] \
                    for i in names[1:]).astype(float)
    exog_name = names[1:]
    dataset = Dataset(data=data,
                      names=names,
                      endog=endog,
                      exog=exog,
                      endog_name=endog_name,
                      exog_name=exog_name)
    return dataset
Example #6
0
def load():
    """
    Load the Spector dataset and returns a Dataset class instance.

    Returns
    -------
    Dataset instance:
        See DATASET_PROPOSAL.txt for more information.
    """
    filepath = dirname(abspath(__file__))
    ##### EDIT THE FOLLOWING TO POINT TO DatasetName.csv #####
    data = recfromtxt(open(filepath + '/spector.csv', "rb"),
                      delimiter=" ",
                      names=True,
                      dtype=float,
                      usecols=(1, 2, 3, 4))
    names = list(data.dtype.names)
    endog = array(data[names[3]], dtype=float)
    endog_name = names[3]
    exog = column_stack(data[i] for i in names[:3]).astype(float)
    exog_name = names[:3]
    dataset = Dataset(data=data,
                      names=names,
                      endog=endog,
                      exog=exog,
                      endog_name=endog_name,
                      exog_name=exog_name)
    return dataset
Example #7
0
def load():
    """
    Loads the RAND HIE data and returns a Dataset class.

    ----------
    endog - structured array of response variable, mdvis
    exog - strucutured array of design

    Returns
    Load instance:
        a class of the data with array attrbutes 'endog' and 'exog'
    """
    filepath = dirname(abspath(__file__))
    ##### EDIT THE FOLLOWING TO POINT TO DatasetName.csv #####
    data = recfromtxt(open(filepath + '/randhie.csv', "rb"),
                      delimiter=",",
                      names=True,
                      dtype=float)
    names = list(data.dtype.names)
    endog = array(data[names[0]]).astype(float)
    endog_name = names[0]
    exog = data[list(names[1:])]
    exog_name = names[1:]
    dataset = Dataset(data=data,
                      names=names,
                      endog=endog,
                      exog=exog,
                      endog_name=endog_name,
                      exog_name=exog_name)
    return dataset
Example #8
0
def load():
    """
    Load the US macro data and return a Dataset class.

    Returns
    -------
    Dataset instance:
        See DATASET_PROPOSAL.txt for more information.

    Notes
    -----
    The macrodata Dataset instance does not contain endog and exog attributes.
    """
    filepath = dirname(abspath(__file__))
    data = recfromtxt(open(filepath + '/macrodata.csv', 'rb'),
                      delimiter=",",
                      names=True,
                      dtype=float)
    names = data.dtype.names
    dataset = Dataset(data=data, names=names)
    return dataset
Example #9
0
def load():
    """
    Load the star98 data and returns a Dataset class instance.

    Returns
    -------
    Load instance:
        a class of the data with array attrbutes 'endog' and 'exog'
    """
    filepath = dirname(abspath(__file__))
    ##### EDIT THE FOLLOWING TO POINT TO DatasetName.csv #####
    names = [
        "NABOVE", "NBELOW", "LOWINC", "PERASIAN", "PERBLACK", "PERHISP",
        "PERMINTE", "AVYRSEXP", "AVSALK", "PERSPENK", "PTRATIO", "PCTAF",
        "PCTCHRT", "PCTYRRND", "PERMINTE_AVYRSEXP", "PERMINTE_AVSAL",
        "AVYRSEXP_AVSAL", "PERSPEN_PTRATIO", "PERSPEN_PCTAF", "PTRATIO_PCTAF",
        "PERMINTE_AVYRSEXP_AVSAL", "PERSPEN_PTRATIO_PCTAF"
    ]
    data = recfromtxt(open(filepath + '/star98.csv', "rb"),
                      delimiter=",",
                      names=names,
                      skip_header=1,
                      dtype=float)
    names = list(data.dtype.names)
    # endog = (successes, failures)
    NABOVE = array(data[names[1]]).astype(float)  # successes
    NBELOW = array(data[names[0]]).astype(float) \
                - array(data[names[1]]).astype(float) # now its failures
    endog = column_stack((NABOVE, NBELOW))
    endog_name = names[:2]
    exog = column_stack(data[i] for i in names[2:]).astype(float)
    exog_name = names[2:]
    dataset = Dataset(data=data,
                      names=names,
                      endog=endog,
                      exog=exog,
                      endog_name=endog_name,
                      exog_name=exog_name)
    return dataset
Example #10
0
def load():
    """
    Load the yearly sunspot data and returns a data class.

    Returns
    --------
    Dataset instance:
        See DATASET_PROPOSAL.txt for more information.

    Notes
    -----
    This dataset only contains data for one variable, so the attributes
    data, raw_data, and endog are all the same variable.  There is no exog
    attribute defined.
    """
    filepath = dirname(abspath(__file__))
    data = recfromtxt(open(filepath + '/sunspots.csv', 'rb'), delimiter=",",
            names=True, dtype=float, usecols=(1))
    names = list(data.dtype.names)
    endog = array(data[names[0]], dtype=float)
    endog_name = names
    dataset = Dataset(data=data, names=names, endog=endog,
            endog_name=endog_name)
    return dataset