*! PR 22-Dec-93. Link and family definitions. STB-18: sg22 program define _jprglld /* family link k */ version 3.1 * di "jprglld sees |`1'| |`2'| |`3'| |`4'|" local f "`1'" local ulink "`2'" local k `3' _glmmapf tocode `f' /* map user-specified family */ local fam "$S_1" /* store code in fam */ local mfixed 1 local m 1 if "`fam'"=="bin" { /* bin takes an optional argument */ parse "`f'", parse(" ") if "`2'"!="" { capture confirm integer number `2' if _rc { _crcunab `2' local m "$S_1" local mfixed 0 } else { if `2'==. | `2'<=0 { di in red /* */ "`2' in family(binomial `2') invalid" exit 198 } local m `2' } } } _glmmapl tocode `ulink' local link "$S_1" local pow "$S_2" /* Apply default links and then check for allowed links fam default link allowed links --------------------------------------------- gau pow 1 pow # bin l l, p, c, pow #, opo # poi pow 0 pow # nb nb nb, pow # gam pow -1 pow # ivg pow -2 pow # Note, k()!=1 is allowed only with family(nb) */ if "`k'"!="1" & "`fam'"!="nb" { di in red "k() allowed only with family(nbinomial)" exit 198 } local scale1 = "`fam'"=="bin" | "`fam'"=="nb" | "`fam'"=="poi" if "`link'"=="" { /* apply defaults */ local link "pow" if "`fam'"=="gau" { local pow 1 } else if "`fam'"=="bin" { local link "l" } else if "`fam'"=="gam" { local pow -1 } else if "`fam'"=="ivg" { local pow -2 } else if "`fam'"=="poi" { local pow 0 } else if "`fam'"=="nb" { local link "nb" } else local link /* !! comment by wwg: the remaining defaults are applied someplace else in the code and, moreoever, "family(gam)" produces the description "Gamma distribution, canonical link" while the equivalent "family(gam) link(pow -1)" produces "Gamma distribution, power link (power = -1)". This should be considered a bug. I would like to see all the defaults set right here. !! comment by wwg: I do not fully understand the [above] restriction and am not convinced it excludes all the cases it should. !! response by jpr, 26-Jan-94 -------------------------- 1. I have now set up all default links arising from null user link. 2. We already know from previous checks that `link' must be one of id, log, pow, opo, nb, l, c or p. Remains to check that l, c, p or opo are used only with binomial family. */ } else { /* check valid fam/link combination */ local binlink = "`link'"=="c" | "`link'"=="l" | /* */ "`link'"=="p" | "`link'"=="opo" if ("`fam'"=="bin" & !(`binlink' | "`link'"=="pow")) | /* */ ("`fam'"!="bin" & `binlink' ) { di in red "link `link' invalid with family `fam'" exit 198 } } * di "returns fam |`fam'| link |`link'| pow |`pow'|" * di " scale1 |`scale1'| m |`m'| mfixed |`mfixied'| global S_1 "`fam'" global S_2 "`link'" global S_3 `pow' global S_4 `scale1' global S_5 `m' global S_6 `mfixed' end