*! 1.0.4 18Jun1997 Jeroen Weesie/ICS STB-39 dm49 program define varcond version 5.0 local varlist "req ex" local if "opt" local in "opt" local options "Cond(str) cons Display Format(str)" local weight "aweight fweight iweight" parse "`*'" * scratch tempvar touse tempname A Vec Val c * code for handling constant if "`cons'" != "cons" { local nocons "nocons" } else local cns "+cons" * selection of rows of implied matrix mark `touse' `if' `in' [`weight'`exp'] markout `touse' `varlist' * spectral decomposition of A = X'*Diag(W)*X, with X the matrix of variables quiet matrix acc `A' = `varlist' if `touse' [`weight'`exp'], `nocons' quiet mat symeigen `Vec' `Val' = `A' local nA colsof(`A') * condition number of X is the square root of the condition number of X'X scalar `c' = sqrt(`Val'[1,1]/`Val'[1,`nA']) * output if "`cond'" == "" | "`display'" != "" { if "`format'" == "" { local format "%10.2g" } quiet count if `touse' > 0 di in gr "condition number of data [" in ye _result(1) in gr /* */ " obs, " in ye colsof(`A') in gr " variables`cns'] = " /* */ in ye `format' scalar(`c') } if "`cond'" != "" { scalar `cond' = `c' } end