Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Biproportional Matrix Balancing and RAS Procedures

Subject: Biproportional Matrix Balancing and RAS Procedures

From: Gregory

Date: 23 Jun, 2010 00:20:16

Message: 1 of 5

I am looking for MATLAB functions that implement a procedure called "Bi-proportional Matrix Balancing" which is also referred to as "RAS". The technique adjusts the elements of an arbitrary matrix so that the row and column sums of the matrix equate to user-supplied initial "control total" or "margin" row and column vectors. The RAS technique is commonly applied to economic input-output matrices as a way of updating an inter-industry transactions matrix from one year to the next. I have found several examples of RAS programs using GAMS but I'm hoping someone has implemented RAS for MATLAB to spare me the job of writing my own code.

Subject: Biproportional Matrix Balancing and RAS Procedures

From: Marco Antonio Marquez

Date: 14 Aug, 2010 02:34:05

Message: 2 of 5

do you have a solution for your problem I try to do an algorith for RAS but I donĀ“t have succes. If you have implemented RAS for MATLAB can you help me?

"Gregory " <greg@bmp.cc> wrote in message <hvrk00$2gq$1@fred.mathworks.com>...
> I am looking for MATLAB functions that implement a procedure called "Bi-proportional Matrix Balancing" which is also referred to as "RAS". The technique adjusts the elements of an arbitrary matrix so that the row and column sums of the matrix equate to user-supplied initial "control total" or "margin" row and column vectors. The RAS technique is commonly applied to economic input-output matrices as a way of updating an inter-industry transactions matrix from one year to the next. I have found several examples of RAS programs using GAMS but I'm hoping someone has implemented RAS for MATLAB to spare me the job of writing my own code.

Subject: Biproportional Matrix Balancing and RAS Procedures

From: Roger Stafford

Date: 14 Aug, 2010 08:33:07

Message: 3 of 5

"Gregory " <greg@bmp.cc> wrote in message <hvrk00$2gq$1@fred.mathworks.com>...
> I am looking for MATLAB functions that implement a procedure called "Bi-proportional Matrix Balancing" which is also referred to as "RAS". The technique adjusts the elements of an arbitrary matrix so that the row and column sums of the matrix equate to user-supplied initial "control total" or "margin" row and column vectors. The RAS technique is commonly applied to economic input-output matrices as a way of updating an inter-industry transactions matrix from one year to the next. I have found several examples of RAS programs using GAMS but I'm hoping someone has implemented RAS for MATLAB to spare me the job of writing my own code.
- - - - - - - - - - -
  As nearly as I can make out from the literature on the subject, the RAS algorithm proceeds in the following manner. Let A be the original matrix of positive elements and let rs and cs be the vectors of row sums and column sums desired after a sufficient number of "biproportional" balances have been carried out. Let rs be a column vector and cs a row vector. (Of course you must have sum(rs)==sum(cs) for these vectors.) Then the basic iteration is very simple:

 R = diag(rs./sum(A,2));
 A1 = R*A;
 S = diag(cs./sum(A1,1));
 A = A1*S;

According to the literature this should be surrounded either by a while-loop that stops when R and S are both sufficiently close to identity matrices or by a for-loop for a large enough number of cycles to ensure convergence.

  I confess I don't have much of a feeling for this economics systems concept since I was not trained in that area, but it seems clear that, provided convergence has been achieved, the resulting A would have the desired row and column sums given by rs and cs.

Roger A. Stafford

Subject: Biproportional Matrix Balancing and RAS Procedures

From: Aline Lang

Date: 21 Sep, 2010 03:27:08

Message: 4 of 5

HI Greg, there has been a discussion on this topic some years ago.
Go to http://www.mathworks.de/matlabcentral/newsreader/view_thread/36666#93319
you will be able to find a simple version of the RAS Method for matlab.

I also had the same problem and even contacted Dr Jojo Jacob, but unfortunately he took a different research approach and ended up never really working with this.
If you get anything please let me know too.

Cheers,
Aline

Subject: Biproportional Matrix Balancing and RAS Procedures

From: Morten Bo

Date: 3 Apr, 2013 20:58:06

Message: 5 of 5

Hi all,

I have implemented a simple version of the RAS algorithm described on the Wikipedia page for a school project (code given below). I run the iterations in eta>=1 rather than eta>=0, such that the estimated RAS matrices are written to cell structure.

% Simulate random matrix
N=3;
Mmatrix=3*randn(N,N)+10;

% Calculate row sums u(i) and column sums v(i)
u=sum(Mmatrix,2);
v=sum(Mmatrix,1)';

% Implement own RAS algorithm, using a seed of ones (zeros optional)
% Initialize RAS matrix, loop index variable eta, and difference diff
RASmatrix{1}=ones(N);
diff=1;
eta=1;

% Iterate as long as any difference is greater than a cutoff
while diff>0.001
    % Calculate intermediate r from marginal sums and previous iteration
    r{eta}=u./sum(RASmatrix{2*eta-1},2);
    
    % Calculate new even iteration of the RAS-matrix
    RASmatrix{2*eta}=diag(r{eta})*RASmatrix{2*eta-1};

    % Calculate intermediate s from marginal sums and previous iteration
    s{eta}=v./sum(RASmatrix{2*eta},1)';

    % Calculate new odd iteration of the RAS-matrix
    RASmatrix{2*eta+1}=RASmatrix{2*eta}*diag(s{eta});
    
    % Update "diff": Convergence measured as largest difference between 2
    % latest iterations
    diff=max(max(abs(RASmatrix{2*eta+1}-RASmatrix{2*eta})))
    
    % Increment eta
    eta=eta+1;
end

% Save final matrix estimated by RAS algorithm
[RASrow,RAScol]=size(RASmatrix);
MmatrixRAS=RASmatrix{RAScol}

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us