Balances an identity numerically approximatively true
[argout1,...,argoutm]=balance_identity(namey,arg1,...,argn)
* namey = a ts, a vector, or a string representing the name of a ts or a vector, equal to the lefthand side of the identity
* arg1,...,argn = arguments that can be:
- a ts
- a matrix
- a string representing the name of a ts or a vector
- a list of such objects
- the string 'prefix=xxxx' where xxxx is the prefix added to the name of the variables to produce the new variables
* argout1,...,argoutm = a variable number if arguments that are:
- either the new rhs terms of the identity
- or the string 'results of macro balance_identity have been saved as variables: ' + the names of the variables the new rhs terms are then put in the calling environment under the original name (exogenousi if the name was not entered between quotes) prefixed by the prefix given by the user
z=grand(20,4,'nor',0,1);x1=z(:,1);x2=z(:,2);x3=z(:,3);y=x1+x2+x3+0.1*z(:,4);[newx1,newx2,newx3]=balance_identity(y,x1,x2,x3) z=grand(20,4,'nor',0,1);x1=z(:,1);x2=z(:,2);x3=z(:,3);y=x1+x2+x3+0.1*z(:,4);balance_identity(y,x1,x2,x3,'prefix=new') z=grand(20,4,'nor',0,1);x1=z(:,1);x2=z(:,2);x3=z(:,3);y=x1+x2+x3+0.1*z(:,4);balance_identity(y,'x1','x2','x3','prefix=new') // In all examples, the relation to balance is y=x1+x2+x3. // In example 1, the new variables are called newx1, newx2 and newx3 and the identity y=newx1+newx2+newx3 holds exactly. // In example 2, the new variables are called new_exogenous1,new_exogenous2,new_exogenous3 and the identity // y=new_exogenous1+new_exogenous2+new_exogenous3holds exactly. // In example 3, the new variables are called new_x1, new_x2 and new_x3 and the identity y=new_x1+new_x2+new_x3 holds exactly. // Note the difference between examples 2 and 3: in order to keep the names of the original exogenous variables, these names // are, classically, entered between quotes. | ![]() | ![]() |