help mata mm_variance0()-------------------------------------------------------------------------------

Title

mm_variance0() -- Population variance

Syntax

real matrixmm_variance0(X,w)

real matrixmm_meanvariance0(X,w)

where

X:real matrix X(rows are observations, columns variables)

w:real colvector w

Description

mm_variance0(X,w)returns the population variance matrix ofX.mm_variance0()differs from official Stata'svariance()(see help formean()) in that it divides the deviation cross products by N instead of N-1, where N is the number of observations. Essentially,

mm_variance0(X,w)=variance(X,w)* (N-1)/NHowever,

mm_variance0()also produces correct results if N==1.

mm_meanvariance0(X,w)returnsmean(X,w)\mm_variance0(X,w).

wspecifies the weight. Specifywas 1 to obtain unweighted results. Rows ofXorwthat contain missing values are omitted from the calculation, which amounts to casewise deletion.

RemarksNone.

Conformability

mm_variance0(X,w),X:n x kw:n x 1or1 x 1result:k x k

mm_meanvariance0(X,w),X:n x kw:n x1 or 1x1result: (k+1)xk

DiagnosticsThe functions omit from the calculation rows that contain missing values unless all rows contain missing values. Then the returned result contains all missing values.

Source codemm_variance0.mata, mm_meanvariance0.mata

AuthorBen Jann, ETH Zurich, jann@soz.gess.ethz.ch

Also seeOnline: help for

[M-5] mean(),moremata