help mog-------------------------------------------------------------------------------

Title

mog-- Produce one way or two way tables of means (or totals) and perform significance tests and quality control checks

Syntax

mogvarname1varname2[varname3] [if] [in] [weight] [,options]

optionsDescription ------------------------------------------------------------------------- Modeltotalchanges the command to estimate totals and not meansSE/Cluster

surveymog will use svyset information for variance estimation and weightingReporting--estimates

decimals(#)number of decimals of estimates, default is 2round(#)estimates will be rounded to multiples of this number (see round function), default is 0--no roundingReporting--significance tests

ref1(#)specifies the reference group to use for varname2, default is 1ref2(#)specifies the reference group to use for varname3, default is 1sl(#)controls the significance level of tests, default is 0.05retestinstructs mog to use estimates from last runnotestsuppresses the insertion of significance test symbols in the tableFwerdisplay information on the family-wise error rateReporting--quality controls

pubstandshow quality control symbols for each estimatepubdichotuse more conservative quality controls if varname1 is dichotomousmincount(#)minimum sample size of each estimate, default is 15symbmincount(string)symbol that indicates the sample size is too low for an estimate, see mincount, default is "X"cvwarning(#)an estimate is "use with caution" grade if its cv is larger than this value and less than cvtoohigh, default is 1/6thsymbwarning(string)symbol used to indicate an estimate falls in the situation described in option cvwarning, default is "E"cvtoohigh(#)an estimate is "too unreliable to use" grade if its cv is larger than this value, default is 1/3rdsymbtoohigh(string)symbol used to indicate an estimate falls in the situation described in option cvtoohigh, default is "F" Reporting--miscellaneousnodetaildisplays only the tablecellwidth(#)controls the width of table cellsvarwidth(#)controls the width of the first column displaying varname2 labels, default is 15underscoresreplaces spaces with underscores in labels--helps when copying data -------------------------------------------------------------------------varname1is the variable for which you want to estimate means.varname2is a categorical variable over which the means are grouped, creating a one way table.varname3is an optional 2nd categorical variable over which the means are also grouped, creating a two way table. Thesvyprefix is not allowed. Use option survey instead. All weight types are allowed; see weight. Weights are not compatible withsurvey. If both are used, weight information is ignored.retestis combatible with changing any reporting option. Useful when estimation is time consuming.

DescriptionThis progam calculates the mean of a variable across all the combinations of categories of up to two other categorical variables (the grouping variables) and produces a one or two way table showing the means. It is essentially a "front-end" for the mean and total commands.

Tests to calculate if there are significant differences from each cell's estimate and the reference category are performed. Symbols are placed in the table to indicate the results of the tests.

mogalso performs quality control tests on the sample sizes and coefficients of variation (1/t-ratio) of each estimate. Symbols are placed in the table to indicate if any of these checks have failed.Copy the fixed width tables into a spreadsheet using COPY TABLE. The underscore option helps copying tables that have labels with spaces.

The command will redisplay the table if it is entered without arguments, as do many stata commands.

Options

ref1andref2change the reference groups for the grouping variables varname2 and varname3. Note, do not put in the actual value of the the variable, put in the integer that represents the ordinal rank of the category you want. For instance, if the grouping variable has values 1, 4, 5.5 and 6, then, if you want the second category to be the reference group, type inref1=2, NOTref1=4. Similarly, if you want the category with value 5.5 to be the reference group, then type inref1=3 (because it is the 3rd category when they are sorted), NOTref1=5.5.

roundspecifies where the estimate should be rounded. Use numbers that work with the round function. Note that even if a number is rounded to an order of 10, it may still be displayed to the number of decimals specified by thedecimaloption.

slspecifies the significance level to be used for the tests. Tests are two-tailed t-tests. Default is 0.05. Other possibilities inlcude 0.01, 0.10, and 0.20. The program will function with any number between 0 and 1.

mincountspecifies the minimum sample size number to check for when searching through the number of observations for each cell in the table. All counts are displayed in a table at the beginning of the output when the program runs. However,mogchecks each value to ensure it is equal to or larger thanmincount. If it isn't, a warning is displayed. If any cell count is less than 2, the program terminates as no variance can be estimated for this estimate. Institutional (company, government body, etc.) guidelines often require a minimum sample size for an estimate to be published and made available for public use, and preclude the possibility of anyone (if the observations are people) to be identifiable. The default is 15.

cellwidthallows the user to change the number of columns taken up by each cell. Cell widths are automatically sized to the estimates size, the number of decimal places and the number of symbols. However, one may wish to increase this number in some cases to allow the column labels to be fully displayed.

underscorereplaces spaces, " ", in the value labels of the grouping variables with underscores, "_". This ensures that the copying process of this table to another program will recognize the columns properly. The default is to NOT make the replacement.

nodetailmakesmogrun without displaying any preliminary checks, estimation output, or test results. Only the final table will be displayed. This is useful to cut back on the amount of output shown when you have already checked the details and you wish to tweak other options. Also useful with theretestoption. The default is to show the details.

retestrerunsmogagain, checking to ensure that the same underlying estimation just performed is being requested again, that is, varname1 to varname3 are the same, if and in statements, and the same weight orsurveyoption, andtotaloption. However, when it is rerun, the command that perfoms the estimation will not execute, often saving a lot of time if it uses variance estimation with bootstrap weights. All reporting options are changable, such as the reference group for testing (ref1andref2), the significance level of the tests (sl), and formatting options likedecimals,cellwidthandunderscores. The default is not to retest. Note: although the estimation commandmean(ortotal) is not rerun, the estimation results from the lastmogcommand must be the active estimation results in memory. This includes both the estimation results saved ine(), andmogresults saved inr().

surveytellsmogto use the information entered in thesvysetcommand regarding the details of the survey design. Thesurveyoption will over-ride any weights specified. Use one or the other, not both. The default is not to use the svyset information. It is operationalized by running the estimation command (meanortotal) with the svy prefix.

fwercomputes the family-wise error rate, based on each tests p-value in the series of tests for the categories of a grouping variable. This may be useful when considering the error rates resulting from useage by a diverse, independent audience who tend to pick and choose what information they need. It provides a sense of the overall error rate for the set of tests in this context. The default is not to make the calculations. Not to be confused with joint tests of significance when a set of test results are used together to develop a conclusion, see test for information on joint testing and associated adjustments used in multiple tests (like bonferonni, sidak, etc.). Use test aftermogto conduct joint tests, if desired. The family-wise error rate, the probability that at least one test in a series of independently used tests is incorrectly rejecting the null. Formula: 1 - (1-pvalue_1)*...*(1-pvalue_i)*...*(1-pvalue_n) , i subscripts tests and n is the number of tests.

pubstandwill place symbols in the table that indicate if an estimate has not passed confidentiality and reliability standards. Estimates with cell counts less thanmincountwill have the symbol X (changable using usingsymbmincount) placed to their right. Estimates with coefficients of variation (1/t-ratio) greater thancvtoohighwill have an F placed to their right. Estimates with cvs betweencvwarningandcvtoohighwill have an E placed to their right. Symbols are changeable withsymbwarningandsymbtoohigh. There can be an X, E, an F, or neither, but never more than one. F and E are mutually exclusive. X replaces E and F.

pubdichot. For dichotomous dependent variables for varname1, for instance, indicator variables showing if an observation has a particular characteristic, the pubdichot option may be used to further slice the samples. They are further sliced by not just the grouping variables, but also the dependent variable, varname1. This may be a requirement of your institutional quality assurance guidelines for total and proportion estimates. One example is the total number of people who are disabled, by age category and sex. If only using thepubstandoption, just the sample sizes in a tabulation by age and sex would be checked againstmincountfor a minium sample size. This may be acceptable for continuous dependent variables. However for estimating totals, when there are rare events where maybe only 2 people are disabled in a particular category, it is this number, and the number not disabled, that are checked individually againstmincount, instead of the sum of the two (representing the overall sample size of the cell).

------------------------------------------------------------------------------- SetupExamples. use autoEstimate the mean of weight over foreign

. mog weight foreignWith rounding and no decimals

. mog weight foreign, dec(0) round(100)Recode rep78

. recode rep78 (1/3=3 "Good") (4=4 "Very Good") (5=5 "ExceptionallyGood"), gen(rep78new)Now estimate means by foreign and rep78new

. mog weight foreign rep78new, dec(0) round(100)Suppress details with

nodetail. mog weight foreign rep78new, dec(0) round(100) nodetailChange the reference group for varname2 (rep78new) to the 3rd category

. mog weight foreign rep78new, dec(0) round(100) nodetail ref2(3)Perform quality control checks

. mog weight foreign rep78new, dec(0) round(100) nodetail ref2(3)pubstandChange minimum sample size per estimate to 5

. mog weight foreign rep78new, dec(0) round(100) nodetail ref2(3)pubstand mincount(5)Increase the cellwidth to see all rep78new labels

. mog weight foreign rep78new, dec(0) round(100) nodetail ref2(3)pubstand mincount(5) cellwidth(15)Insert underscores to aid in pasting to a spreadsheet (use copy table option in Edit or shortcut menu)

. mog weight foreign rep78new, dec(0) round(100) nodetail ref2(3)pubstand mincount(5) cellwidth(15) undDo not perform significance tests

. mog weight foreign rep78new, dec(0) round(100) nodetail ref2(3)pubstand mincount(5) cellwidth(15) und notestShow only formatted numbers

. mog weight foreign rep78new, dec(0) round(100) nodetail notest------------------------------------------------------------------------------- Setup. use autoMake a dummay variable to indicate foreign cars

. xi i.foreignRecode rep78

. recode rep78 (1/3=3), gen(rep78new)Estimate the total of weight over foreign and rep78new

. mog weight foreign rep78new, total dec(0)Estimate the total of foreign over rep78new

. mog _Iforeign_1 rep78new, total dec(0)-------------------------------------------------------------------------------

Saved results

mogsaves estimation results ine(). See mean or total for details on what is saved by the respective estimation commands.

mogsaves one result inr():Macros

r(cmdtext)command as typed

AuthorMatt Hurst Statistics Canada matt.hurst@statcan.gc.ca Last revision: December 9, 2010

Also seeManual:

[R] mean;[R] totalHelp:

[R] mean,[R] mean postestimation;[R] summarize,[R] total,[R] tabulate,[R] test