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
GRoberts86
Level I

Line of fit and intercept column formula, help with an error

JMP18.1.1

 

I'm working with measurement data, where I'd like to compute a line of fit at a particular datapoint, using the neighbouring datapoints. To then obtain an x-axis intercept for y=0.

Looking around and trying to solve this myself, it seems I can do it using either the 'Linear Regression' or 'Least Squares Solve' function in JMP..

I've done this in a column formula (with an if statement to identify the datapoint about which to evaluate):

 

x = J( 2, 1, 0 );
y = J( 2, 1, 0 );
x[1, 1] = Lag( :y_column, 1 );
x[2, 1] = Lag( :y_column, -1 );
y[1, 1] = Lag( :x_column, 1 );
y[2, 1] = Lag( :x_column, -1 );
Coeffs = Linear Regression( y, x )[1];
Coeffs[1];

 

This code produces the right output, but when it runs it throws up an error:

'Unable to estimate the variance of parameter estimates because the rank of X equals the number of rows of X'

I don't really understand what the problem here is. I only want the intercept anyway. Is there a simple way to fix this? Or turn off the warning?

I can try a similar approach with the Least Squares function, but that throws up the same error.

I've made an example table which shows the problem. Rerun the formula on that table to see the error.

Thanks

4 REPLIES 4
GRoberts86
Level I

Re: Line of fit and intercept column formula, help with an error

I seem to have immediately fixed this myself by increasing the number of datapoints in the regression to 3, including the current datapoint.

 

	x = J( 3, 1, 0 );
	y = J( 3, 1, 0 );
	x[1, 1] = Lag( :y_column, 1 );
	x[2, 1] = :y_column;
	x[3, 1] = Lag( :y_column, -1 );
	y[1, 1] = Lag( :x_column, 1 );
	y[2, 1] = :x_column;
	y[3, 1] = Lag( :x_column, -1 );
	Coeffs = Linear Regression( y, x )[1];
	Coeffs[1];

This stops the error coming up, which may be ok for now. I would still like to possibly calculate intercepts from only 2 points in future though. So my question still stands.

Thanks

jthi
Super User

Re: Line of fit and intercept column formula, help with an error

You could include the point at which you are doing the calculation at (so 3 points instead of two)

If(Row() > 1 & Row() < Col Number(:y_column),
	Linear Regression(:y_column[Index(Row() - 1, Row() + 1)]`, :x_column[Index(Row() - 1, Row() + 1)]`)[1][1];
,
	.
);
-Jarmo
GRoberts86
Level I

Re: Line of fit and intercept column formula, help with an error

I now have a problem with the intercept value returned not being correct...

 

I'll have to show an excerpt of real data to show this. File attached.

I'm evaluating the intercept at the row where another column is at it's maximum value.

The script is taking the values correctly from the adjacent rows, I can see in the log output that it is forming the matrix correctly.

It gives an output value for the intercept of '-1053478758'. But if I take those x/y values manually into a separate table and run a bivariate line fit on them, it gives an intercept of '-1.22', which is correct.

 

Code:

If( :"dlogIds/dVgs"n == Col Maximum( :"dlogIds/dVgs"n ),
	x = J( 3, 1, 0 );
	y = J( 3, 1, 0 );
	x[1, 1] = Lag( :I_Drain Abs, 1 );
	x[2, 1] = :I_Drain Abs;
	x[3, 1] = Lag( :I_Drain Abs, -1 );
	y[1, 1] = Lag( :V_GATE, 1 );
	y[2, 1] = :V_GATE;
	y[3, 1] = Lag( :V_GATE, -1 );
	Show( x );
	Show( y );
	Coeffs = Linear Regression( y, x )[1];
	Coeffs[1];
)

Can't figure out at all why it's not right....

jthi
Super User

Re: Line of fit and intercept column formula, help with an error

Could be some accuracy thing/oversight/bug. You could contact JMP support @mzwald 

Names Default To Here(1);

ys = [-0.999986, -1.49994, -1.99997];
xs = [1.3500e-12, 1.0600e-10, 1.9700e-9];
xs2 = Matrix(Eval List({1.3500e-12*10^12, 1.0600e-10*10^12, 1.9700e-9*10^12}));

ls = Linear Regression(ys, xs, << print to log);
ls2 = Linear Regression(ys, xs2, << print to log);


dt = New Table("",
	New Column("Y", Numeric, Continuous, Values(ys)),
	New Column("X1", Numeric, Continuous, Values(xs)),
	New Column("X2", Numeric, Continuous, Values(xs2)),
);

biv1 = dt << Bivariate(Y(:Y), X(:X1), Fit Line({Line Color({230, 159, 0})}));
biv_estimates1 = Report(biv1)[Outline Box("Parameter Estimates"), Number Col Box("Estimate")];
Show(biv_estimates1 << get);

biv2 = dt << Bivariate(Y(:Y), X(:X2), Fit Line({Line Color({230, 159, 0})}));
biv_estimates2 = Report(biv2)[Outline Box("Parameter Estimates"), Number Col Box("Estimate")];
Show(biv_estimates2 << get);

Write();
-Jarmo