Confidence interval for the Geometric mean from Distribution platformHello,
Is there any shortcut to get the Confidence interval for the Geometric mean from the distribution platform?
AnalyticsRe: Confidence interval for the Geometric mean from Distribution platformThat result is unavailable from the Distribution platform or any other place in JMP. The computation may be scripted using the guidance in this DO Loop blog post. SAS/IML is similar to JMP JSL, so the conversion is not too bad.
Re: Confidence interval for the Geometric mean from Distribution platformHi Mark,
Thank you very much for the quick feedback.
Re: Confidence interval for the Geometric mean from Distribution platformI didn't compare details with the guidance that @Mark_Bailey quotes, but you can try the bootstrap too (either interactively or via JSL). For example:
NamesDefaultToHere(1);
// Get some data
dt = Open("$SAMPLE_DATA/Big Class.jmp");
// Use Distribution
dist = dt << Distribution(
Continuous Distribution(
Column( :height ),
Quantiles( 0 ),
Vertical( 0 ),
Outlier Box Plot( 0 ),
Customize Summary Statistics(
Mean( 0 ),
Std Dev( 0 ),
Std Err Mean( 0 ),
Upper Mean Confidence Interval( 0 ),
Lower Mean Confidence Interval( 0 ),
N( 0 ),
N Missing( 0 ),
Geometric Mean( 1 )
)
)
);
// Bootstrp the statistic in question (note 'dt2' is a list)
dt2 = Report(dist)[TableBox(1)] << Bootstrap(1000);
// Inspect the bootstrp distribution
dist2 = dt2[2] << runScript("Distribution");
// Get the confidence interval for the statistic by inspection or further JSL . . .Re: Confidence interval for the Geometric mean from Distribution platformAnother way, without JSL but making the same assumptions of a Log-Normal distribution; using the distribution platform, analyze the natural log of the data. The mean and confidence bounds acquired can then be back-transformed via Exp. The resulting interval is a confidence interval on the GM.
Re: Confidence interval for the Geometric mean from Distribution platformAnd if you just care about the interval, you could get it using this kind of approach, which is much quicker since you don't have the overhead of all the platform launches that the generality of Bootstrap requires:
NamesDefaultToHere(1);
// Get some data
dt = Open("$SAMPLE_DATA/Big Class.jmp");
n = NRow(dt);
dataVec = dt[0, "height"]; // Get the requisite data as a vector
nb = 100000; // Number of bootstrsp samples
gms = J(nb, 1, .); // Vector to hold the geometric mean of each bootstrap sample
for(s=1, s<=nb, s++, // Loop over bootstrap samples
pickMe = J(n, 1, RandomInteger(1, n)); // Indices of elements to compose this bootstrap sample
bootstrapSampleVec = dataVec[pickMe]; // Values in this bootstrap sample
gm = exp(Mean(ln(bootstrapSampleVec))); // Geometric mean of this bootstrap sample
gms[s] = gm;
);
gm95 = Quantile(0.95, gms);
gm05 = Quantile(0.05, gms);
Print("The Geometric Mean lies betweeen "||Char(Round(gm05, 3))||" and "||Char(Round(gm95, 3))||".");
Probably this code could be parallelised to make it even quicker, but with the loss of some readability.
Re: Confidence interval for the Geometric mean from Distribution platformHello Ian,
That's perfect. Thanks a lot for the suggestion.