<?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: Creating columns from Linear Fit Constants (slope, intercept) in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Creating-columns-from-Linear-Fit-Constants-slope-intercept/m-p/254265#M49920</link>
    <description>&lt;P&gt;I like data table processing, so many times I use the Make Combined Data Table and then go from there.&amp;nbsp; Here is a version of the script that is what I think your final desired output is&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to here(1);
dt = Current Data Table(); //Big Class active 

biv = Bivariate(
		Y( :height ),
		X( :weight ),
		by(	:sex, :age ),
		Fit Line( {Line Color( {212, 73, 88} )}, save predicteds ),
);
report(biv[1])["Parameter Estimates"][tablebox(1)]&amp;lt;&amp;lt;make combined data table(invisible);

biv &amp;lt;&amp;lt; close window;

dtIntSlope = current data table();

dtTrans = dtIntSlope &amp;lt;&amp;lt; Transpose(invisible,
	columns( :Estimate ),
	Transpose selected rows only( 1 ),
	By( :age, :sex ),
	Label( :Term ),
	Label column name( "Term" ),
	Output Table( "Transpose of Untitled 60" )
);

dtTrans:weight &amp;lt;&amp;lt; set name("Slope");
dtTrans:age &amp;lt;&amp;lt; data type(numeric)&amp;lt;&amp;lt;modeling type(ordinal);

dt &amp;lt;&amp;lt; Update(
	With( dtTrans),
	Match Columns( :age = :age, :sex = :sex ),
	Add Columns from Update Table( :Intercept, :Slope )
);

close(dtIntSlope, nosave );
close(dtTrans, nosave );&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 25 Mar 2020 16:46:42 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2020-03-25T16:46:42Z</dc:date>
    <item>
      <title>Creating columns from Linear Fit Constants (slope, intercept)</title>
      <link>https://community.jmp.com/t5/Discussions/Creating-columns-from-Linear-Fit-Constants-slope-intercept/m-p/254223#M49908</link>
      <description>&lt;P&gt;Trying to pull constants, slope and intercept, from the linear fit formula across multiple plots.&amp;nbsp; I am using Big Class as an example.&amp;nbsp; I make a Bi-variate plot across different parameters, next I make a linear fit for each plot and create a new column for the predicted values.&amp;nbsp; I want to take the Linear Fit formula constants and create two new columns that hold the slope and intercept from that formula for each row. Here is what I have so far, I am stuck where I save the formula from the linear fit, but can't quite pull the formula values into a column, I think I want to use the expr() function but I am not sure, any help would be greatly appreciated, thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table(); //Big Class active 

biv = Bivariate(
		Y( :height ),
		X( :weight ),
		by(	:sex, :age ),
		Fit Line( {Line Color( {212, 73, 88} )}, save predicteds ),
);
biv &amp;lt;&amp;lt; (curve[1] &amp;lt;&amp;lt; save predicteds);
Column( N Cols( dt ) ) &amp;lt;&amp;lt; set name( "Linear Fit" );

myFormula = Column(dt, "Linear Fit") &amp;lt;&amp;lt; getFormula;

// Stuck here want to use the "Linear Fit" formula and create a column for the slope in the formula
// and another for the intercept pulled from the predicted formula in "Linear Fit"

dt &amp;lt;&amp;lt; NewColumn("Slope", Numeric, Continous, expr(left(myFormula,5)));
dt &amp;lt;&amp;lt; NewColumn("Intercept", Numeric, Continous, );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2020 15:19:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Creating-columns-from-Linear-Fit-Constants-slope-intercept/m-p/254223#M49908</guid>
      <dc:creator>avatar4293</dc:creator>
      <dc:date>2020-03-25T15:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: Creating columns from Linear Fit Constants (slope, intercept)</title>
      <link>https://community.jmp.com/t5/Discussions/Creating-columns-from-Linear-Fit-Constants-slope-intercept/m-p/254247#M49911</link>
      <description>&lt;P&gt;I believe you will have an easier time getting the slope and intercept values from all of the different combinations of sex and age, if you create a combined data table from the estimates table.&amp;nbsp; It will allow you to parse through the outputted data table and easily get the values you want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table(); //Big Class active 

biv = Bivariate(
		Y( :height ),
		X( :weight ),
		by(	:sex, :age ),
		Fit Line( {Line Color( {212, 73, 88} )}, save predicteds ),
);
report(biv[1])["Parameter Estimates"][tablebox(1)]&amp;lt;&amp;lt;make combined data table;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Mar 2020 15:45:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Creating-columns-from-Linear-Fit-Constants-slope-intercept/m-p/254247#M49911</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-03-25T15:45:21Z</dc:date>
    </item>
    <item>
      <title>Re: Creating columns from Linear Fit Constants (slope, intercept)</title>
      <link>https://community.jmp.com/t5/Discussions/Creating-columns-from-Linear-Fit-Constants-slope-intercept/m-p/254256#M49914</link>
      <description>&lt;P&gt;Jim,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought about that, but I lose connection with the original Big Class data set, i.e "Name", I guess its just as easy to go back and join the two tables instead of trying to get too fancy in one table.&amp;nbsp; Thanks!&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2020 16:13:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Creating-columns-from-Linear-Fit-Constants-slope-intercept/m-p/254256#M49914</guid>
      <dc:creator>avatar4293</dc:creator>
      <dc:date>2020-03-25T16:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: Creating columns from Linear Fit Constants (slope, intercept)</title>
      <link>https://community.jmp.com/t5/Discussions/Creating-columns-from-Linear-Fit-Constants-slope-intercept/m-p/254265#M49920</link>
      <description>&lt;P&gt;I like data table processing, so many times I use the Make Combined Data Table and then go from there.&amp;nbsp; Here is a version of the script that is what I think your final desired output is&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to here(1);
dt = Current Data Table(); //Big Class active 

biv = Bivariate(
		Y( :height ),
		X( :weight ),
		by(	:sex, :age ),
		Fit Line( {Line Color( {212, 73, 88} )}, save predicteds ),
);
report(biv[1])["Parameter Estimates"][tablebox(1)]&amp;lt;&amp;lt;make combined data table(invisible);

biv &amp;lt;&amp;lt; close window;

dtIntSlope = current data table();

dtTrans = dtIntSlope &amp;lt;&amp;lt; Transpose(invisible,
	columns( :Estimate ),
	Transpose selected rows only( 1 ),
	By( :age, :sex ),
	Label( :Term ),
	Label column name( "Term" ),
	Output Table( "Transpose of Untitled 60" )
);

dtTrans:weight &amp;lt;&amp;lt; set name("Slope");
dtTrans:age &amp;lt;&amp;lt; data type(numeric)&amp;lt;&amp;lt;modeling type(ordinal);

dt &amp;lt;&amp;lt; Update(
	With( dtTrans),
	Match Columns( :age = :age, :sex = :sex ),
	Add Columns from Update Table( :Intercept, :Slope )
);

close(dtIntSlope, nosave );
close(dtTrans, nosave );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Mar 2020 16:46:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Creating-columns-from-Linear-Fit-Constants-slope-intercept/m-p/254265#M49920</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-03-25T16:46:42Z</dc:date>
    </item>
  </channel>
</rss>

