⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mf__equilrc.hlp

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 HLP
📖 第 1 页 / 共 2 页
字号:
{smcl}
{* 31mar2005}{...}
{cmd:help mata _equilrc()}
{hline}
{* index equilibration}{...}
{* index _equilrc()}{...}
{* index _equilr()}{...}
{* index _equilc()}{...}
{* index _perhapsequilrc()}{...}
{* index _perhapsequilr()}{...}
{* index _perhapsequilc()}{...}
{* index rowscalefactors()}{...}
{* index colscalefactors()}{...}

{title:Title}

{p 4 8 2}
{bf:[M-5] _equilrc() -- Row and column equilibration}

{title:Syntax}

{p 8 12 2}
{it:void}{bind:         }
{cmd:_equilrc(}{it:numeric matrix A}{cmd:,}
{it:r}{cmd:,}
{it:c}{cmd:)}

{p 8 12 2}
{it:void}{bind:         }
{cmd:_equilr(}{it:numeric matrix A}{cmd:,}
{it:r}{cmd:)}

{p 8 12 2}
{it:void}{bind:         }
{cmd:_equilc(}{it:numeric matrix A}{cmd:,}
{it:c}{cmd:)}


{p 8 12 2}
{it:real scalar}{bind:  }
{cmd:_perhapsequilrc(}{it:numeric matrix A}{cmd:,}
{it:r}{cmd:,}
{it:c}{cmd:)}

{p 8 12 2}
{it:real scalar}{bind:  }
{cmd:_perhapsequilr(}{it:numeric matrix A}{cmd:,}
{it:r}{cmd:)}

{p 8 12 2}
{it:real scalar}{bind:  }
{cmd:_perhapsequilc(}{it:numeric matrix A}{cmd:,}
{it:c}{cmd:)}


{p 8 12 2}
{it:real colvector}
{cmd:rowscalefactors(}{it:numeric matrix A}{cmd:)}

{p 8 12 2}
{it:real rowvector}
{cmd:colscalefactors(}{it:numeric matrix A}{cmd:)}


{p 4 4 2}
The types of {it:r} and {it:c} are irrelevant because they are overwritten.


{title:Description}

{p 4 4 2}
{cmd:_equilrc(}{it:A}{cmd:,} {it:r}{cmd:,} {it:c}{cmd:)}
performs row and column equilibration (balancing) on matrix {it:A}, 
returning the equilibrated matrix in {it:A}, the row-scaling factors in 
{it:r}, and the column-scaling factors in {it:c}.

{p 4 4 2}
{cmd:_equilr(}{it:A}{cmd:,} {it:r}{cmd:)}
performs row equilibration on matrix {it:A}, 
returning the row-equilibrated matrix in {it:A} and the row-scaling factors in 
{it:r}.

{p 4 4 2}
{cmd:_equilc(}{it:A}{cmd:,} {it:c}{cmd:)}
performs column equilibration on matrix {it:A}, 
returning the column-equilibrated matrix in {it:A} and the column-scaling
factors in {it:c}.

{p 4 4 2}
{cmd:_perhapsequilrc(}{it:A}{cmd:,} {it:r}{cmd:,} {it:c}{cmd:)}
performs row and/or column equilibration on matrix {it:A} -- as is 
necessary and which decision is made by {cmd:_perhapsequilrc()} -- returning
the equilibrated matrix in {it:A}, the row-scaling factors in {it:r}, 
the column-scaling factors in {it:c}, and returning 0 (no equilibration 
performed), 1 (row equilibration performed), 2 (column equilibration 
performed), or 3 (row and column equilibration performed).

{p 4 4 2}
{cmd:_perhapsequilr(}{it:A}{cmd:,} {it:r}{cmd:)}
performs row equilibration on matrix {it:A} -- if necessary and which 
decision is made by {cmd:_perhapsequilr()} -- returning 
the equilibrated matrix in {it:A}, the row-scaling factors in {it:r}, 
and returning 0 (no equilibration performed) or 1 (row equilibration performed).

{p 4 4 2}
{cmd:_perhapsequilc(}{it:A}{cmd:,} {it:c}{cmd:)}
performs column equilibration on matrix {it:A} -- if necessary and which 
decision is made by {cmd:_perhapsequilc()} -- returning 
the equilibrated matrix in {it:A}, the column-scaling factors in {it:c}, 
and returning 0 (no equilibration performed) or 1 (column equilibration
performed).

{p 4 4 2}
{cmd:rowscalefactors(}{it:A}{cmd:)} 
returns the row-scaling factors of {it:A}.

{p 4 4 2}
{cmd:colscalefactors(}{it:A}{cmd:)} 
returns the column-scaling factors of {it:A}.


{title:Remarks}

{p 4 4 2}
Remarks are presented under the headings 

	{bf:Introduction}
	{bf:Is equilibration necessary?}
	{bf:The _equil*() family of functions}
	{bf:The _perhapsequil*() family of functions}
	{bf:rowscalefactors() and colscalefactors()}


{title:Introduction}

{p 4 4 2}
The purpose of equilibration (also known as balancing) is to take 
a matrix with poorly scaled rows and columns, such as 

	{res}       {txt}          1             2
	    {c TLC}{hline 29}{c TRC}
	  1 {c |}  {res}1.00000e+10   5.00000e+10{txt}  {c |}
	  2 {c |}  {res}2.00000e-10   8.00000e-10{txt}  {c |}
	    {c BLC}{hline 29}{c BRC}

{p 4 4 2} 
and produce a related matrix such as 

	{res}       {txt}  1     2
	    {c TLC}{hline 13}{c TRC}
	  1 {c |}  {res} .2     1{txt}  {c |}
	  2 {c |}  {res}.25     1{txt}  {c |}
	    {c BLC}{hline 13}{c BRC}

{p 4 4 2} 
that will yield improved accuracy in, for instance, the solution to linear 
systems.  The improved matrix above has been row equilibrated.  All we 
did was find the maximum of each row of the original, and then divide 
the row by its maximum.  If we were to take the result and repeat the 
process on the columns -- divide each column by the column's maximum -- 
we would obtain

	{res}       {txt} 1    2
	    {c TLC}{hline 11}{c TRC}
	  1 {c |}  {res}.8    1{txt}  {c |}
	  2 {c |}  {res} 1    1{txt}  {c |}
	    {c BLC}{hline 11}{c BRC}

{p 4 4 2}
which is the row-and-column equilibrated form of the original matrix.

{p 4 4 2}
In terms of matrix notation, equilibration can be thought about in terms 
of multiplication by diagonal matrices.  
The row-equilibrated form of {it:A} is {it:R}{it:A}, where {it:R} contains 
the reciprocals of the row maximums on its diagonal.  The column-equilibrated 
form of {it:A} is {it:A}{it:C}, where {it:C} contains the reciprocals of the 
column maximums on its diagonal.  The row-and-column equilibrated form of 
{it:A} is {it:RAC}, where {it:R} contains the reciprocals of the 
row maximums of {it:A} on its diagonal, and {it:C} contains the reciprocals of
the column maximums of {it:RA} on its diagonal.

{p 4 4 2}
Say we wished to find the solution {it:x} to

		{it:Ax} = {it:b}

{p 4 4 2}
We could compute the solution by solving for {it:y} in the equilibrated system 

		({it:RAC}){it:y} = {it:Rb}

{p 4 4 2}
and then setting 

		{it:x} = {it:Cy}

{p 4 4 2}
Thus routines that perform equilibration need to return to you, in some
fashion, {it:R} and {it:C}.  The routines here do that by returning 
{it:r} and {it:c}, the reciprocals of the maximums in vector form.
You could obtain {it:R} and {it:C} from them by coding 

		{it:R} = {cmd:diag(}{it:r}{cmd:)}
		{it:C} = {cmd:diag(}{it:c}{cmd:)}

{p 4 4 2}
but that is not in general necessary, and it is wasteful of memory.  In code,
you will need to multiply by {it:R} and {it:C}, and you can do that 
using the {cmd::*} operator with {it:r} and {it:c}:

		{it:RA}      <->     {it:r}{cmd::*}{it:A}
		{it:AC}      <->     {it:A}{cmd::*}{it:c}
		{it:RAC}     <->     {it:r}{cmd::*}{it:A}{cmd::*}{it:c}


{title:Is equilibration necessary?}

{p 4 4 2}
Equilibration is not a panacea.  Equilibration can reduce the condition number
of some matrices and thereby improve the accuracy of the solution to linear
systems, but equilibration is not guaranteed to reduce the condition number,
and counter examples exist in which equilibration actually decreases the
accuracy of the solution.  That said, you have to look long and hard to find
such examples.

{p 4 4 2}
Equilibration is not especially computationally expensive, but neither is it
cheap, especially when you consider the extra computational costs of using the
equilibrated matrices.  In statistical contexts, equilibration may buy you
little because matrices are already nearly equilibrated.  Data analysts know
variables should be on roughly the same scale, and observations are assumed to
be draws from an underlying distribution.  The computational cost of
equilibration is probably better spent somewhere else.  For instance, consider
obtaining regression estimates from {it:X}{bf:'}{it:X} and {it:X}{bf:'}{it:y}.
The gain from equilibrating {it:X}{bf:'}{it:X} and {it:X}{bf:'}{it:y}, or even
from equilibrating the original {it:X} matrix, is nowhere near that from the
gain to be had in removal of the means before {it:X}{bf:'}{it:X} and
{it:X}{bf:'}{it:y} are formed.

{p 4 4 2}
In the example in the previous section, we showed you a matrix that 
assuredly benefited from equilibration.  Even so, it is worth noting 
that, after row equilibration, column equilibration was unnecessary.
It is often the case that solely row or column equilibration is sufficient, and
in those cases, while the extra equilibration will do no numerical harm, 
it will burn computer cycles.  And, as we have already argued, some matrices
do not need equilibration at all.  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -