Logo

scikits.statsmodels.tools.tools.add_constant

scikits.statsmodels.tools.tools.add_constant(data, prepend=False)[source]

This appends a column of ones to an array if prepend==False.

For ndarrays it checks to make sure a constant is not already included. If there is at least one column of ones then the original array is returned. Does not check for a constant if a structured or recarray is given.

Parameters :

data : array-like

data is the column-ordered design matrix

prepend : bool

True and the constant is prepended rather than appended.

Returns :

data : array

The original array with a constant (column of ones) as the first or last column.

Notes

Warning

The default of prepend will be changed to True in the next release of statsmodels. We recommend to use an explicit prepend in any permanent code.

Previous topic

sm.tools.tools.unsqueeze

Next topic

sm.tools.tools.categorical

This Page