scaleunit_ function(S) { # Scale a data set so that the presumption of unit variance for # the mixture components is tenable. This can be done prior to # invocation of normal.S, so that the tests performed therein # are meaningful. # # Required Input: # S is a vector of data # # Outputs: # S is a vector of scaled data S_ S-mean(S) n_ length(S) # Suppose S_i ~ Normal(0, sigma^2). One could estimate sigma by # the sample standard deviation of the S_i and scale the data # accordingly. The problem with doing this is that, in the # presence of heterogeneity, the overall variance is calibrated # to 1; we really want the mixture components to have unit # variance. A better option is to scale by a different estimate # of sigma. Noting that Var(S_i^2) = 2 sigma^4, we can estimate # sigma by the fourth root of one-half the sample variance of the # squared observations. In the presence of heterogeneity, the # overall variance can then be calibrated to something more than 1. SS_ S^2 sig_ (((sum(SS^2)-sum(SS)^2/n)/(n-1))/2)^.25 S_ S/sig return(S) result }