ETHZ_Logo RAMSES_Logo_Right   RAMSES   RAMSES_Logo_Left Systems Ecology  
Start    search button      Modules:   A-Z   Function   Layer        QuickRefs:   DM   AuxLib   AuxLibE   SciLib   EasyMW   MW   ISIS   RMSLib

DEFINITION MODULE AR1Fit;

  (*******************************************************************

    Module  AR1Fit     (Version 1.0)

      Copyright (c) 1995-2006 by Dimitrios Gyalistras and ETH Zurich.

    Purpose   Fits the parameters of a multivariate AR1-process.

    Remarks   See e.g. Richardson, C.W., 1981:  Stochastic simulation
              of daily precipitation, temperature and solar radiation.
              Water Resour. Res., 17:1, p182-190.


    Programming

      o Design
        Dimitrios Gyalistras      12/05/1995

      o Implementation
        Dimitrios Gyalistras      12/05/1995


    ETH Zurich
    Systems Ecology
    CHN E 35.1
    Universitaetstrasse 16
    8092 Zurich
    SWITZERLAND

    URLs:
        <mailto:RAMSES@env.ethz.ch>
        <http://www.sysecol.ethz.ch>
        <http://www.sysecol.ethz.ch/SimSoftware/RAMSES>


    Last revision of definition:  24/05/2002  AF

  *******************************************************************)


  IMPORT Errors;
  FROM LgMatrices IMPORT LMatrix, LVector;


  (******************************************************************)

  CONST  (* result codes returned *)
    allOk   = Errors.allOk;
    notDone = Errors.onlyAnInsert;

  (*
    Note: the dimensions of all LVector and LMatrix objects used below
    are determined automatically via procedures LgMatrices.NElems,
    LgMatrices.NRows and LgMatrices.NCols.
  *)


  PROCEDURE GetCovMats( data          : LMatrix;
                        errorIfMisCov : BOOLEAN;
                        M             : LVector;  (* out *)
                        C0            : LMatrix;  (* out *)
                        C1            : LMatrix;  (* out *)
                        VAR resCode   : INTEGER;
  					    VAR errTxt    : ARRAY OF CHAR );

  (*
    Given in data realizations of a N-dimensional stochastic process
    (variables = rows (!), realizations = columns), this procedure
    estimates the lag-0 and lag-1 corelation matrices C0 and C1 of the
    process.  M returns the time series means.  If errorIfMisCov = TRUE
    and a covariance is a missing value, the procedure will return
    FALSE.
  *)


  PROCEDURE FitAR1( C0          : LMatrix;
                    C1          : LMatrix;
                    A           : LMatrix;  (* out *)
                    B           : LMatrix;  (* out *)
                    VAR resCode : INTEGER;
  					VAR errTxt  : ARRAY OF CHAR );

  (*
    Given the N x N sized lag-0 and lag-1 covariance matrices C0 and
    C1, this procedure determines the N x N sized matrices A and B of
    the correspoding stochastic AR(1) process

       x(k+1) = A*x(k) + B*e(k),

    where k is the time step, x is the state vector with E[x(i)]
    = 0 for all system states i, and e is a vector of independent
    random components from a normal distribution N(0,1).

    NOTE: The procedure does not accept missing values in the
          covariance matrices!
  *)



END AR1Fit.

  Contact RAMSES@env.ethz.ch Last updated: 25-Jul-2011 [Top of page]