Package parsimony :: Package datasets :: Package simulate :: Module simulate :: Class LinearRegressionData
[hide private]
[frames] | no frames]

Class LinearRegressionData

source code

   object --+    
            |    
SimulatedData --+
                |
               LinearRegressionData

Returns data for linear regression that is generated such that we know
the exact solution.

The data generated by this function is fit to the Linear regression + L1 +
L2 + Smoothed total variation function, i.e.:

    f(b) = (1 / 2).|Xb - y|²_2 + sum_{i=1}^N l_i.P_i(b),

where the P_i(.) are penalty functions.

Parameters
----------
penalties : List or tuple. The penalties to add to the linear regression
        function.

X0 : Numpy array (n-by-p). The initial matrix to use when building data.
        This matrix carries the desired correlation structure of the
        generated data. The generated data will be a column-scaled version
        of this matrix.

e : Numpy array (n-by-1). The error vector e = Xb - y. This vector carries
        the desired distribution of the residual.

snr : Positive float. Signal-to-noise ratio between model and residual.

intercept : Boolean. Whether or not to include an intercept variable. This
        variable is not penalised. Note that if intercept is True, then e
        will be centred.

Returns
-------
X : Numpy array (n-by-p). The generated X matrix.

y : Numpy array (n-by-1). The generated y vector.

beta : Numpy array (p-by-1). The regression vector with the correct snr (if
        snr is given).

Nested Classes [hide private]

Inherited from SimulatedData: __metaclass__

Instance Methods [hide private]
 
__init__(self, penalties, X0, e, snr=None, intercept=False)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
load(self, beta)
Generate the simulated data.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  __abstractmethods__ = frozenset([])
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, penalties, X0, e, snr=None, intercept=False)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

load(self, beta)

source code 
Generate the simulated data.

Parameters
----------
beta : Numpy array (p-by-1). The regression vector to generate data
        from.

Overrides: SimulatedData.load