cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar

Is it possible to create an overlay plot representing confidence intervals?

I have lower bound and upper bound of the confidence interval for each estimate already available in my data, I just want to draw it using JMP. All the blogs I have found are regarding generating and drawing confidence intervals with JMP. Any help would be very welcome, thank you very much.

7 REPLIES 7
ian_jmp
Level X

Re: Is it possible to create an overlay plot representing confidence intervals?

One way would be to use the 'Range Plot' option in Overlay Plot. To se an example, do 'File > New > New Script', cut and paste the code below, then do 'Edit > Run Script':

// Fudge some data

dt = Open("$SAMPLE_DATA/Big Class.jmp");

UCIcol = dt << NewColumn("Weight UCI", Numeric, Continuous, Formula(:Weight + RandomNormal(10, 1)));

LCIcol = dt << NewColumn("Weight LCI", Numeric, Continuous, Formula(:Weight - RandomNormal(10, 1)));

// Use 'Range Plot' option in Overlay (add a 'Row()' variable to play the x role)

op = dt << Overlay Plot(

X( Transform Column( "Row", Ordinal, Formula( Row() ) ) ),

Y( :Weight UCI, :Weight LCI ),

Range Plot( 1 ),

Show Points( 0 ),

SendToReport(

Dispatch( {}, "Overlay Plot Graph", FrameBox, {Frame Size( 688, 243 )} )

)

);

Re: Is it possible to create an overlay plot representing confidence intervals?

Hi Ian,

Thank you for your help. I am a new JMP user and so far have only been

using the menu options to generate graphs, manipulating all my data and

running models first in SAS. To create the overlay graph, I import by my

results dataset into JMP and select in menu bar "Graph" then "Overlay

plot". Is it possible to draw confidence interval using this menu, or

please could you explain to me how practically to run the code you sent me

earlier?

Thank you,

Myriam Alexander

ian_jmp
Level X

Re: Is it possible to create an overlay plot representing confidence intervals?

Hello Myriam,

I'm sure you'll soon get used to JMP.

If you do want to run the code above, then the instructions to do that precede it. The first line to cut starts with '// Fudge . . . ' (the '//' actually denotes a comment line).

But, yes, it's easy to do it interactively. In the Overlay Plot launch dialog, assign the two columns with the upper and lower limits to the 'Y' role, and then the column you want to the 'X' role. When you hit OK, the report appears. Go to the little red triangle at the top of the report (in the 'Overlay Plot' outline node) to select the options you need. You should see 'Range Plot' as one of these.

pmroz
Super User

Re: Is it possible to create an overlay plot representing confidence intervals?

Hello Myriam,

You might find it easier using Graph Builder.  Suppose you have a table with the following columns: X, Y, LCL and UCL.  Bring up GB on this table.  Drag X to the X axis.  Highlight Y, LCL, UCL and drag to the Y axis.  Click the icon for points, and then shift click the icon for vertical bars.  Right-click inside the graph and select Bar > Bar Style > Interval.  Then, under Points (left side) click on Variables and deselect LCL and UCL.  Under Bar click on Variables and deselect Y.  Should look like this:

10525_GB Confidence Intervals.png

If you run the code shown below inside a script window you'll get the final result.  Uses JMP 11 btw.

New Table( "Untitled",

      Add Rows( 10 ), New Column( "X", Numeric, Continuous, Format( "Best", 12 ),

            Set Values( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] )

      ),

      New Column( "Y", Numeric, Continuous, Format( "Best", 12 ),

            Set Values( [2, 5, 3, 6, 4, 7, 5, 8, 6, 9] )

      ),

      New Column( "LCL", Numeric, Continuous, Format( "Best", 12 ),

            Set Values( [1, 3, 2, 2, 2, 5, 3, 7, 5, 7] )

      ),

      New Column( "UCL", Numeric, Continuous, Format( "Best", 12 ),

            Set Values( [3, 8, 5, 8, 6, 9, 8, 9, 7, 10] )

      )

);

Graph Builder(

      Show Control Panel( 0 ),

      Variables( X( :X ), Y( :Y ), Y( :LCL, Position( 1 ) ), Y( :UCL, Position( 1 ) )

      ),

      Elements(

            Points( X, Y( 1 ), Legend( 4 ), Jitter( 1 ) ),

            Bar( X, Y( 2 ), Y( 3 ), Legend( 5 ), Bar Style( "Interval" ),

                  Summary Statistic( "Mean" )

            )

      )

);

Re: Is it possible to create an overlay plot representing confidence intervals?

Thank you very much for this step by step explanation, this answers my

question.

Best wishes,

Myriam Alexander

rc_hertzy
Level III

Re: Is it possible to create an overlay plot representing confidence intervals?

Can this be done for two Y variables? I have Y1, Y1LCL, Y1UCL, Y2, Y2LCL, Y2UCL

The Graph Builder script works if only one Y variable. When I added 3 lines for the corresponding Y2 values, they only show up as points.

I can show both Y vars with CLs using a Group variable when Ys are not in separate columns, but I get two graphs, one above the other, whereas I want both Ys and their intervals on one graph (thus creation of Y1, etc).

Here is the script using a Group:

 

Graph Builder(

	Variables(
		X( :ID ), 
		Y( :Predicted Dose ), 
		Y( :Lower 95%, Position( 1 ) ), 
		Y( :Upper 95%, Position( 1 ) ), 
		Group Y( :BMR% )

	), 

	Elements(
		Bar( X, Y( 2 ), Y( 3 ), Y( 1 ), Legend( 16 ), Bar Style( "Interval" ) )
	), 

	SendToReport( Dispatch( {"Bar"}, "", OutlineBox, {Close( 0 )} ) )

);

 

ian_jmp
Level X

Re: Is it possible to create an overlay plot representing confidence intervals?

Indeed, as Peter says Graph Builder may be a better choice - Possibly I over interpreted the 'overlay plot' in the title of the thread.

As a relative newcomer to JMP, you should be aware that there are almost always many ways to get things done - That's one of its charms . . .