.- help for ^orthpoly^ (STB-25: sg37) .- Create orthogonal polynomials ----------------------------- ^orthpoly^ varname [weight] [^if^ exp] [^in^ range] ^,^ { ^g^enerate^(^varlist^)^ ^p^oly^(^matname^)^ } [ ^d^egree^(^#^)^ ] ^aweight^s and ^fweight^s are allowed; see help @weights@. Description ----------- ^orthpoly^ computes orthogonal polynomials for a variable "varname". Either ^generate()^ or ^poly()^ or both must be specified. Options ------- ^degree(^#^)^ specifies the highest degree polynomial to include. Orthogonal polynomials of degree 1, 2,..., d = # are computed. Default is 1. ^generate(^varlist^)^ creates d new variables (of type double) containing orthogonal polynomials of degree 1, 2,..., d evaluated at "varname". The varlist must either contain exactly d new variable names or be abbreviated using either "newvar1-newvard" or "newvar*". For both styles of abbreviation, new variables newvar1, newvar2,..., newvard are generated. ^poly(^matname^)^ creates a (d+1)x(d+1) matrix called "matname" containing the coefficients of the orthogonal polynomials. The orthogonal polynomial of degree i is matname[i, d+1] + matname[i, 1]*varname + matname[i, 2]*varname^^2 + ... + matname[i, i]*varname^^i Note: The coefficients corresponding to the constant term are placed in the last column of the matrix. Examples -------- . ^orthpoly x, deg(3) gen(p1 p2 p3)^ . ^orthpoly x, deg(3) gen(p1-p3)^ . ^orthpoly x, deg(3) gen(p*)^ . ^orthpoly x, deg(3) poly(A)^ . ^orthpoly x, deg(3) gen(p*) poly(A)^ Suppose x1=x, x2=x^^2, x3=x^^3, and x4=x^^4 are natural polynomials and px1, px2, px3, and px4 are the corresponding orthogonal polynomials. If we compute . ^orthpoly x, deg(4) gen(px*) poly(P)^ . ^regress y px1-px4^ . ^matrix bp = get(_b)^ . ^matrix b1 = bp*P^ . ^regress y x1-x4^ . ^matrix b2 = get(_b)^ then b1 and b2 will be the same. (This is the rationale for the ordering of the rows and columns of P.) Methods and formulas -------------------- The orthogonal polynomials are computed using the Christoffel-Darboux recurrence formula. They are normalized so that X'DX = NI, where D = diag(w1, w2,..., wn) with w1, w2,..., wn the weights (all 1 if weights not specified), and N is the sum of the weights. (If the weights are ^aweight^s, they are first normalized so that N is the number of observations.) Author ------ Bill Sribney Stata Corporation 702 University Drive East College Station, TX 77840 Phone: 409-696-4600 800-782-8272 Fax: 409-696-4601 email: tech_support@@stata.com Also see -------- STB: STB-25 sg37