Package ivs :: Package statistics :: Module linearregression :: Class HarmonicModel
[hide private]
[frames] | no frames]

Class HarmonicModel

source code


Class to implement a harmonic model function.

The class implements a harmonic model of the form

y(x) = a_0 * sin(2*pi*f1*t) + a_1 * cos(2*pi*f1*t) + a_2 * sin(2*pi*f2*t) + a_3 * cos(2*pi*f2*t) + ...

where y are the responses (observables), x are the covariates, the a_i are the regression coefficients (to be determined). Such a class provides a more convenient short way of creating a harmonic model.

Remarks:

Instance Methods [hide private]
HarmonicModel
__init__(self, covariate, covariateName, freqList, freqNameList, maxNharmonics=1, covMatrix=None)
Initialiser of HarmonicModel class, with *known* frequencies.
source code

Inherited from LinearModel: __add__, __str__, conditionNumber, containsRegressorName, copy, degreesOfFreedom, designMatrix, fitData, hatMatrix, nObservations, nParameters, pseudoInverse, regressorNames, singularValues, someRegressorNameContains, standardCovarianceMatrix, submodels, traceHatMatrix, withIntercept

Inherited from LinearModel (private): _singularValueDecompose

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, covariate, covariateName, freqList, freqNameList, maxNharmonics=1, covMatrix=None)
(Constructor)

source code 

Initialiser of HarmonicModel class, with *known* frequencies.

Example:

>>> time = linspace(0,10,100)
>>> hm = HarmonicModel(time, "t", [2.34, 8.9], ["f_1", "f_2"], 1)
Parameters:
  • covariate (ndarray) - an array of size N with the covariate values, where N is the number of observations.
  • covariateName (string) - a (preferably short) name of the covariate. E.g. "t", or "x".
  • freqList (list) - the frequencies (unit: inverse unit of covariate)
  • freqNameList (list) - the (preferably short) names of the frequencies. E.g. "f_1" or "nu_1".
  • maxNharmonics (list) - integer values > 1. The number of harmonics for each frequency. For example: 1 : f_1, f_2, ... 2 : f_1, 2*f_1, f_2, 2*f_2, ...
  • covMatrix (ndarray) - square array containing the covariance matrix of the observations. Weights, and correlations can hence be taken into account.
Returns: HarmonicModel
an instance of HarmonicModel, subclass of LinearModel
Overrides: object.__init__