*! 1.0.4 18Jun1997 Jeroen Weesie/ICS STB-39 dm49 program define varnull version 5.0 local varlist "req ex" local if "opt" local in "opt" local options "Rank(str) Null(str) Cons Display Format(str)" local weight "aweight fweight iweight" parse "`*'" * scratch tempvar touse tempname A * code for handling constant local nv: word count `varlist' if "`cons'" != "cons" { local nocons "nocons" } else { local cns "+cons" local nv = `nv' + 1 } * selection of rows of implied matrix mark `touse' `if' `in' [`weight'`exp'] markout `touse' `varlist' * form A = X'WX quiet mat acc `A' = `varlist' if `touse' [`weight'`exp'], `nocons' * use matrix-oriented program to obtain null-space if "`null'" != "" { local Null "`null'" } else { tempname Null } if "`rank'" != "" { local Rank "`rank'" } else { tempname Rank } matnull `A', null(`Null') rank(`Rank') * display if "`null'" == "" | "`display'" != "" { local d = `nv' - `Rank' if "`format'" != "" { local fmt "format(`format')" } di _n in gr "Rank of the variables`cns' is " in ye `Rank' di in gr "There exist " in ye `d' /* */ in gr " linear dependencies between the variables" if `d' > 0 { di _n in gr "Null space of the variables`cns'" mat list `Null', noheader `fmt' } } end