Example Weighting Configurations
This section shows show sample configuration for simple weighted databases.
Single Fact Table and One Weight
weightings.xml
XML
<DATABASE_WEIGHTINGS dbid="CustomerSurvey2015" formula_file="formulas.xml">
<WEIGHT id="Person Weight" type="Single" level="Person"/>
<COEFF measure="Person" weight_id="Person Weight">
<VAR id="N" value="25814697"/>
<VAR id="n" value="59053 "/>
</COEFF>
</DATABASE_WEIGHTINGS>
In this example:
- The database ID is
CustomerSurvey2015
. - There is only one fact table,
Person
. - There is only one weighting factor. The display name of the measure that contains this weighting factor is
Person Weight
. - The sample size consists of 59,053 records, representing a total population of 25,814,697.
Multiple Fact Tables and Multiple Weights
weightings.xml
XML
<DATABASE_WEIGHTINGS dbid="LabourForceSurvey" formula_file="formulas.xml">
<WEIGHT id="Family Weight" type="Single" level="Family"/>
<WEIGHT id="Person Weight" type="Single" level="Person"/>
<WEIGHT id="Person Income Weight" type="Single" level="Person"/>
<WEIGHT id="Household Weight" type="Single" level="Household"/>
<COEFF measure="Person" weight_id="Person Weight">
<VAR id="N" value="58336835"/>
<VAR id="n" value="133815 "/>
</COEFF>
<COEFF measure="Person" weight_id="Person Income Weight">
<VAR id="N" value="24161932"/>
<VAR id="n" value="1469"/>
</COEFF>
<COEFF measure="Family" weight_id="Family Weight">
<VAR id="N" value="26817302"/>
<VAR id="n" value="60475"/>
</COEFF>
<COEFF measure="Household" weight_id="Household Weight">
<VAR id="N" value="24680901"/>
<VAR id="n" value="56102"/>
</DATABASE_WEIGHTINGS>
In this example:
- The database ID is
CustomerSurvey2015
. - There are three fact tables,
Person
,Family
andHousehold
. - There are four weighting factors:
Person Weight
andPerson Income Weight
are the display names of fields containing weights in thePerson
fact table.Family Weight
is a weight in theFamily
fact table.Household Weight
is a weight in theHousehold
fact table.
Example Formulas File
The following is a simple formulas file defining only Sum, Weighted Sum and Standard Error of Sum:
formulas.xml
XML
<WEIGHTFORMULAS id="type1">
<TAGS measure="measure" weight="weight" level="level" all="all"/>
<LABELTEMPLATE expression="%FUNCTION of %MEASURE"/>
<!-- Sum -->
<!-- Single Measure Single Weight No Derivation -->
<FORMULA id="WSUM" name="Weighted Sum" type="SMSWND">
<UDF id="wx_udf"/>
</FORMULA>
<FORMULA id="WRSEDC" name="Standard Error of Sum" type="SMSW" level="true">
<UDF id="wx_udf"/>
<UDF id="wxx_udf"/>
<COEFF>n</COEFF>
<COEFF>N</COEFF>
<DER_EXPRESSION>(Sqrt(("wxx_udf" - ("wx_udf"*"wx_udf"/"weight"))/(("weight" - 1) * "level")*"weight"*"weight" + ("N"-"weight")*(1-"n"/"N")*"weight"/"n"))</DER_EXPRESSION>
</FORMULA>
<!-- /Sum -->
<!-- Unweighted Sum -->
<FORMULA id="UWSUM" name="Unweighted Sum" type="UNW">
<!-- Single Measure Single Weight -->
</FORMULA>
<!-- /Unweighted Sum -->
<UDF_DEFINITION id="x_udf">
<UDF_FORMULA>("measure")</UDF_FORMULA>
</UDF_DEFINITION>
<UDF_DEFINITION id="w_udf">
<UDF_FORMULA>("weight")</UDF_FORMULA>
</UDF_DEFINITION>
<UDF_DEFINITION id="wx_udf">
<UDF_FORMULA>("measure"*"weight")</UDF_FORMULA>
</UDF_DEFINITION>
<UDF_DEFINITION id="wxx_udf">
<UDF_FORMULA>("measure"*"measure"*"weight")</UDF_FORMULA>
</UDF_DEFINITION>
<UDF_DEFINITION id="ww_udf">
<UDF_FORMULA>("weight"*"weight")</UDF_FORMULA>
</UDF_DEFINITION>
</WEIGHTFORMULAS>