<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Line of fit and intercept column formula, help with an error in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Line-of-fit-and-intercept-column-formula-help-with-an-error/m-p/820692#M99948</link>
    <description>&lt;P&gt;Could be some accuracy thing/oversight/bug. You could contact JMP support &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/9802"&gt;@Mark_Zwald&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;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, &amp;lt;&amp;lt; print to log);
ls2 = Linear Regression(ys, xs2, &amp;lt;&amp;lt; 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 &amp;lt;&amp;lt; 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 &amp;lt;&amp;lt; get);

biv2 = dt &amp;lt;&amp;lt; 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 &amp;lt;&amp;lt; get);

Write();&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 04 Dec 2024 18:44:20 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2024-12-04T18:44:20Z</dc:date>
    <item>
      <title>Line of fit and intercept column formula, help with an error</title>
      <link>https://community.jmp.com/t5/Discussions/Line-of-fit-and-intercept-column-formula-help-with-an-error/m-p/820414#M99899</link>
      <description>&lt;P&gt;JMP18.1.1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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..&lt;/P&gt;&lt;P&gt;I've done this in a column formula (with an if statement to identify the datapoint about which to evaluate):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;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];&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code produces the right output, but when it runs it throws up an error:&lt;/P&gt;&lt;P&gt;'Unable to estimate the variance of parameter estimates because the rank of X equals the number of rows of X'&lt;/P&gt;&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;I can try a similar approach with the Least Squares function, but that throws up the same error.&lt;/P&gt;&lt;P&gt;I've made an example table which shows the problem. Rerun the formula on that table to see the error.&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2024 17:34:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Line-of-fit-and-intercept-column-formula-help-with-an-error/m-p/820414#M99899</guid>
      <dc:creator>GRoberts86</dc:creator>
      <dc:date>2024-12-03T17:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: Line of fit and intercept column formula, help with an error</title>
      <link>https://community.jmp.com/t5/Discussions/Line-of-fit-and-intercept-column-formula-help-with-an-error/m-p/820425#M99901</link>
      <description>&lt;P&gt;I seem to have immediately fixed this myself by increasing the number of datapoints in the regression to 3, including the current datapoint.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;	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];&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2024 17:46:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Line-of-fit-and-intercept-column-formula-help-with-an-error/m-p/820425#M99901</guid>
      <dc:creator>GRoberts86</dc:creator>
      <dc:date>2024-12-03T17:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: Line of fit and intercept column formula, help with an error</title>
      <link>https://community.jmp.com/t5/Discussions/Line-of-fit-and-intercept-column-formula-help-with-an-error/m-p/820426#M99902</link>
      <description>&lt;P&gt;You could include the point at which you are doing the calculation at (so 3 points instead of two)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(Row() &amp;gt; 1 &amp;amp; Row() &amp;lt; Col Number(:y_column),
	Linear Regression(:y_column[Index(Row() - 1, Row() + 1)]`, :x_column[Index(Row() - 1, Row() + 1)]`)[1][1];
,
	.
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Dec 2024 18:00:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Line-of-fit-and-intercept-column-formula-help-with-an-error/m-p/820426#M99902</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-12-03T18:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: Line of fit and intercept column formula, help with an error</title>
      <link>https://community.jmp.com/t5/Discussions/Line-of-fit-and-intercept-column-formula-help-with-an-error/m-p/820579#M99926</link>
      <description>&lt;P&gt;I now have a problem with the intercept value returned not being correct...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll have to show an excerpt of real data to show this. File attached.&lt;/P&gt;&lt;P&gt;I'm evaluating the intercept at the row where another column is at it's maximum value.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;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];
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Can't figure out at all why it's not right....&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2024 12:54:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Line-of-fit-and-intercept-column-formula-help-with-an-error/m-p/820579#M99926</guid>
      <dc:creator>GRoberts86</dc:creator>
      <dc:date>2024-12-04T12:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: Line of fit and intercept column formula, help with an error</title>
      <link>https://community.jmp.com/t5/Discussions/Line-of-fit-and-intercept-column-formula-help-with-an-error/m-p/820692#M99948</link>
      <description>&lt;P&gt;Could be some accuracy thing/oversight/bug. You could contact JMP support &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/9802"&gt;@Mark_Zwald&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;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, &amp;lt;&amp;lt; print to log);
ls2 = Linear Regression(ys, xs2, &amp;lt;&amp;lt; 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 &amp;lt;&amp;lt; 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 &amp;lt;&amp;lt; get);

biv2 = dt &amp;lt;&amp;lt; 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 &amp;lt;&amp;lt; get);

Write();&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Dec 2024 18:44:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Line-of-fit-and-intercept-column-formula-help-with-an-error/m-p/820692#M99948</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-12-04T18:44:20Z</dc:date>
    </item>
    <item>
      <title>Re: Line of fit and intercept column formula, help with an error</title>
      <link>https://community.jmp.com/t5/Discussions/Line-of-fit-and-intercept-column-formula-help-with-an-error/m-p/820801#M99968</link>
      <description>&lt;P&gt;I was wondering if it was a precision issue. Looks like something in that function isn't handling the input with enough significant figures.&lt;/P&gt;&lt;P&gt;It works for now to use your fix and multiply the x axis values to something it can handle.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2024 08:37:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Line-of-fit-and-intercept-column-formula-help-with-an-error/m-p/820801#M99968</guid>
      <dc:creator>GRoberts86</dc:creator>
      <dc:date>2024-12-05T08:37:10Z</dc:date>
    </item>
    <item>
      <title>Re: Line of fit and intercept column formula, help with an error</title>
      <link>https://community.jmp.com/t5/Discussions/Line-of-fit-and-intercept-column-formula-help-with-an-error/m-p/820824#M99969</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/62807"&gt;@GRoberts86&lt;/a&gt;&amp;nbsp;: For completeness, the "error" message&amp;nbsp; 'Unable to estimate the variance of parameter estimates because the rank of X equals the number of rows of X' is because you only have two points, and you are connecting them with a straight line. Therefore, there is no variability around the line...i.e., you aren't really carrying out a &lt;EM&gt;statistical&lt;/EM&gt; procedure, you are just &lt;EM&gt;mathematically&lt;/EM&gt; connecting two points. However, you using a statistical package to do that, via matrix algebra as shown here.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.stat.cmu.edu/~cshalizi/mreg/15/lectures/13/lecture-13.pdf" target="_blank" rel="noopener"&gt;https://www.stat.cmu.edu/~cshalizi/mreg/15/lectures/13/lecture-13.pdf&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The statistical procedure you called (Linear Regression( y, x )[1]) attempts to do much more than just mathematically connect two points. It also provides confidence intervals, p-values, etc. for the slope and intercept. But in your case, since you only have two points (rank of X =2), there is no variability and hence no confidence intervals etc.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, long story short, the "error" is really just a notification that there will be no &lt;EM&gt;statistical&lt;/EM&gt;&amp;nbsp;(as different from &lt;EM&gt;mathematical&lt;/EM&gt;) output.&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2024 13:35:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Line-of-fit-and-intercept-column-formula-help-with-an-error/m-p/820824#M99969</guid>
      <dc:creator>MRB3855</dc:creator>
      <dc:date>2024-12-05T13:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: Line of fit and intercept column formula, help with an error</title>
      <link>https://community.jmp.com/t5/Discussions/Line-of-fit-and-intercept-column-formula-help-with-an-error/m-p/820858#M99973</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/7073"&gt;@MRB3855&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I realised that after thinking about it for a bit. If you're only working with 2 points, then good old 'equation of a line' y=mc+c is the appropriate thing to be using.&lt;/P&gt;&lt;P&gt;Still, a 'silent' flag would be nice haha.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2024 14:33:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Line-of-fit-and-intercept-column-formula-help-with-an-error/m-p/820858#M99973</guid>
      <dc:creator>GRoberts86</dc:creator>
      <dc:date>2024-12-05T14:33:26Z</dc:date>
    </item>
  </channel>
</rss>

