(*:Mathematica:: V2.1 *) (*:Context:: "exturner`" *) (*:Title:: Turner's syndrome *) (*:Summary:: a single loglinear model for partially observed categorical data *) (*:References:: Nordheim, E.V. (1984) Inference from Nonrandomly Missing Categorical Data: An Example from a Genetic Study on Turner's Syndrome. JASA, 79, 772-780. *) (*:Keywords:: loglinear, contingency table *) (*:Requirements:: clm` *) (*:History:: 1992 Stuart G. Baker *) Clear[exturner,createconfig1]; y=Transpose[{{30,15, 22,10, 23,4, 12,3, 14,3, 102,26, 52,16, 17,10, 7,8, 22,5, 41,8,6,6,3, 39,37,3,1,8}}]; mod1={"RA,RT"}; mod2={"RA"}; mod3={"RT"}; mod4={"RY,RA,RT"}; mod5={"RAY"}; mod6={"RY,RA"}; mod7={"RTY"}; mod8={"RY,RT"}; mod9={"RY"}; mod={mod1,mod2,mod3,mod4,mod5,mod6,mod7,mod8,mod9} exturner[y_,modelname_]:= Module[{q1,w1,g1,h1,z1,x1, func1,dim1,configset1, n,q,w,g,h,z,x, components,mstepfunc,msteparg, truoct,alloct, rmata1,rmatb1,rmata2,rmatb2, rmata,rmatb, parametername,rationame, c,model,ratio,name}, (*model 1 *) q1=Identity; w1=J[40,1,0]; g1=Id[40]; h1=(#2)&; z1=J[40,1,0]; (*R, T, A, Y*) dim1={2,2,5,2}; configset1=createconfig1[modelname]; x1=CategoricalDesignMatrix[dim1,configset1,VariablesVary->"SlowtoFast"]; func1=NIPFCount; arg1={dim1,configset1}; (*combination*) n={1}; q={q1}; w={w1}; g={g1}; h={h1}; z={z1}; x={x1}; c=BlockDiag[Id[20],Id[10] ~Dir~ J[1,2]]; components={n,q,w,g,h,z,x}; mstepfunc={func1}; msteparg={arg1}; model={components,mstepfunc,msteparg}; ratio="None"; parametername=ToString /@ CategoricalParameters[dim1,configset1]; rationame=Automatic; name={parametername,rationame}; Return[{c,model,ratio,name}]] /;MemberQ[mod,modelname] (*R=1 T(trustworthiness)=2, A(ascertainment)=3, Y=4*) createconfig1[modelname_]:= Switch[modelname[[1]], "RA,RT", {{2,3,4},{1,3},{1,2}}, "RA", {{2,3,4},{1,3}}, "RT", {{2,3,4},{1,2}}, "RY,RA,RT", {{2,3,4},{1,4},{1,3},{1,2}}, "RAY", {{2,3,4},{1,3,4}}, "RY,RA", {{2,3,4},{1,4},{1,3}}, "RTY", {{2,3,4},{1,2,4}}, "RY,RT", {{2,3,4},{1,4},{1,2}}, "RY", {{2,3,4},{1,4}}]