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
learning_JSL
Level IV

how do I compute +/- one standard deviation around my linear regression line?

Hi - I am trying to get jmp to compute a standard deviation around my linear regression line which I am using as a predictive model.  Specifically, for each new (future) sample point, I would like to add + and minus one standard deviation to the regression result for that point.  I know how to compute confidence intervals but not a standard deviation.  Once I see how to make this computation I would like to place it into a script to automate the results and plot versus time.  Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions

Re: how do I compute +/- one standard deviation around my linear regression line?

I think that the USGS plot might be a sample mean and standard deviation, not a predicted mean and standard deviation from a model.

 

Any model must assume something about the variance of the response. For example, linear regression models assume that it is constant (independent of conditions). Many common models make this assumption. You stated that you are using linear regression, so I assumed that it is constant and estimated by the RMSE.

View solution in original post

8 REPLIES 8
txnelson
Super User

Re: how do I compute +/- one standard deviation around my linear regression line?

Here is an example of one way to do this

txnelson_0-1647988777152.png

names default to here(1);
// Open Data Table: big class.jmp
// → Data Table( "big class" )
dt = Open( "/C:/Program Files/SAS/JMPPRO/14/Samples/Data/big class.jmp" );

biv = dt << Bivariate( Y( :Weight ), X( :Height ), invisible );
biv << fit line(  {Save Predicteds} );
biv << close window;

// New column: Column 7
Data Table( "big class" ) << New Column( "Upper",
	Numeric,
	"Continuous",
	Format( "Best", 12 ),
	Formula(
	:Predicted weight + Col Std Dev( :weight )

));


// New column: Column 8
Data Table( "big class" ) << New Column( "lower",
	Numeric,
	"Continuous",
	Format( "Best", 12 ),Formula(
	:Predicted weight - Col Std Dev( :weight )
)
	
);

Graph Builder(
	Size( 528, 454 ),
	Show Control Panel( 0 ),
	Variables(
		X( :height ),
		Y( :Predicted weight ),
		Y( :Upper, Position( 1 ) ),
		Y( :lower, Position( 1 ) )
	),
	Elements(
		Points( X, Y( 1 ), Y( 2 ), Y( 3 ), Legend( 12 ) ),
		Smoother( X, Y( 1 ), Y( 2 ), Y( 3 ), Legend( 13 ) )
	)
);

 

Jim
learning_JSL
Level IV

Re: how do I compute +/- one standard deviation around my linear regression line?

Thank you txnelson.   I notice that your example shows straightline plots.  Would the script work for future values that are predicted by my regression formula?  My regression formula predicts the value of ecoli (dependent) based on turbidity (independent), and I am trying to create a model where I use future real-time turbidity values to predict ecoli..... and also show +/ one standard deviation.  The plot below is my goal.  

 

One thing I am unclear about is the "col std dev( :weight)" portion from your example.  I need to think through what std dev is being computed.  In my example, it would not be turbidity, nor would it be ecoli.  Instead it would be a standard deviation of the regression fit, correct?  (I assume that would be the std dev of the slope?)  I appreciate any advise!

 

learning_JSL_0-1648036684891.png

 

txnelson
Super User

Re: how do I compute +/- one standard deviation around my linear regression line?

The lines drawn are derived from the predicted values, therefore they will follow any regression lime you fit. The choice of what column to use in the col std dev probability be the predicted column

Jim
learning_JSL
Level IV

Re: how do I compute +/- one standard deviation around my linear regression line?

Thanks very much txnelson.  This jsl will help once I work out the underlying statistics.  I appreciate it!

Re: how do I compute +/- one standard deviation around my linear regression line?

You should not use the Col Std Dev() function to compute the standard deviation about the line. This function returns the unconditional estimated SD of the response variation. I think you want the conditional SD. This quantity is reported as the RMSE in the Summary of Fit table in the regression report. It is conditioned on the predictor.

learning_JSL
Level IV

Re: how do I compute +/- one standard deviation around my linear regression line?

Thank you Mark.   In my example plot (screenshot) above, the +/- one standard deviation range fluctuates in size around the predicted (i.e. regressed) ecoli value.  However, the RMSE is a fixed value based on the regression fit.  Obviously, there is something I am missing.  Under what conditions would a SD fluctuate in size through time as in the example plot?  (The plot is from a USGS webpage so it has undoubtedly been fully vetted.)   https://www2.usgs.gov/water/southatlantic/ga/bacteria/#:~:text=coli)%20concentrations.-,E.,three%20s....

 

Re: how do I compute +/- one standard deviation around my linear regression line?

I think that the USGS plot might be a sample mean and standard deviation, not a predicted mean and standard deviation from a model.

 

Any model must assume something about the variance of the response. For example, linear regression models assume that it is constant (independent of conditions). Many common models make this assumption. You stated that you are using linear regression, so I assumed that it is constant and estimated by the RMSE.

learning_JSL
Level IV

Re: how do I compute +/- one standard deviation around my linear regression line?

Thanks Mark.  I appreciate your help and insights!