cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
RicardoCosta
Level II

Confidence interval for the Geometric mean from Distribution platform

Hello,

Is there any shortcut to get the Confidence interval for the Geometric mean from the distribution platform?

 

 

 

 

Ricardo Costa
3 ACCEPTED SOLUTIONS

Accepted Solutions

Re: Confidence interval for the Geometric mean from Distribution platform

That 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.

View solution in original post

ian_jmp
Level X

Re: Confidence interval for the Geometric mean from Distribution platform

And 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.

View solution in original post

RicardoCosta
Level II

Re: Confidence interval for the Geometric mean from Distribution platform

Hello Ian,

 

That's perfect. Thanks a lot for the suggestion. 

Ricardo Costa

View solution in original post

6 REPLIES 6

Re: Confidence interval for the Geometric mean from Distribution platform

That 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.

RicardoCosta
Level II

Re: Confidence interval for the Geometric mean from Distribution platform

Hi Mark,

 

Thank you very much for the quick feedback.

Ricardo Costa
MRB3855
Super User

Re: Confidence interval for the Geometric mean from Distribution platform

Another 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.   

ian_jmp
Level X

Re: Confidence interval for the Geometric mean from Distribution platform

I 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 . . .
ian_jmp
Level X

Re: Confidence interval for the Geometric mean from Distribution platform

And 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.

RicardoCosta
Level II

Re: Confidence interval for the Geometric mean from Distribution platform

Hello Ian,

 

That's perfect. Thanks a lot for the suggestion. 

Ricardo Costa