<?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: create formula to generate columns of design matrix in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/create-formula-to-generate-columns-of-design-matrix/m-p/209839#M42074</link>
    <description>&lt;P&gt;My apologies. I read your request again and realized that none of the JSL functions will help in this case. They are intended to create the columns for the effects of categorical factors for the linear regression.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a script that will take the matrix with the factor levels and create the matrix with a column for each term in a quadratic polynomial:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here( 1 );

x2fx = Function( { x }, { n factors, n treat, fx, f, f1, f2 },
	n factors = N Col( x );
	n treat = N Row( x );
	fx = J( n treat, 1, 1 );
	For( f = 1, f &amp;lt;= n factors, f++,
		fx ||= x[0,f];
	);
	For( f1 = 1, f1 &amp;lt; n factors, f1++,
		For( f2 = f1+1, f2 &amp;lt;= n factors, f2++,
			fx ||= x[0,f1] :* x[0,f2];
		);
	);
	For( f = 1, f &amp;lt;= n factors, f++,
		fx ||= x[0,f]^2;
	);
	fx;
);

X = [1 10,
     2 20,
     3 10,
     4 20,
     5 15,
     6 15];

D = x2fx( X );

Show( D );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It is not that hard to make your own functions.&lt;/P&gt;</description>
    <pubDate>Wed, 22 May 2019 15:02:23 GMT</pubDate>
    <dc:creator>Mark_Bailey</dc:creator>
    <dc:date>2019-05-22T15:02:23Z</dc:date>
    <item>
      <title>create formula to generate columns of design matrix</title>
      <link>https://community.jmp.com/t5/Discussions/create-formula-to-generate-columns-of-design-matrix/m-p/11507#M11027</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am a beginner to use JMP, and cannot find similar answers to my questions in JMP community. Suppose that I have a data table with several columns, and the user needs to select the column from the data table and then a design matrix will be generated according the selected column. The selected column and the design matrix will be created in a new data table. But this is not enough. If the user want to change the value in the selected column in the new data table, then the design matrix will be updated accordingly. My problems is that I cannot update the design matrix correctly with the code below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// create a window to select column&lt;/P&gt;&lt;P&gt;// omit some code to create the window&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CheckAndConvert = Expr(&lt;/P&gt;&lt;P&gt;selectedColumns = c &amp;lt;&amp;lt; Get Items;&lt;/P&gt;&lt;P&gt;// If inputs are valid, we continue&lt;/P&gt;&lt;P&gt;If(N Items(selectedColumns) &amp;gt; 0,&lt;/P&gt;&lt;P&gt;win &amp;lt;&amp;lt; Close Window;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A = Column(selectedColumns);&lt;/P&gt;&lt;P&gt;s = A &amp;lt;&amp;lt; GetAsMatrix;&amp;nbsp;&amp;nbsp; // extract the select column in s&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// create the new data table "Design Matrix"&lt;/P&gt;&lt;P&gt;dt = New Table("Design Matrix"); &lt;/P&gt;&lt;P&gt;dt &amp;lt;&amp;lt; New Column("slice", Numeric, Values(s[0, 1]));&amp;nbsp; // copy s to the column "slice" in the new data table&lt;/P&gt;&lt;P&gt;// create corresponding columns of design matrix and adding them into the new data table&lt;/P&gt;&lt;P&gt;For( i=1, i&amp;lt;=Col Max(dt:slice), i++,&lt;/P&gt;&lt;P&gt;&amp;nbsp; dt &amp;lt;&amp;lt; New Column("X"||Char(i), Numeric, &lt;/P&gt;&lt;P&gt;&amp;nbsp; After Last,&lt;/P&gt;&lt;P&gt;&amp;nbsp; Formula(&lt;/P&gt;&lt;P&gt;&amp;nbsp; If(dt:slice == i, 1,&lt;/P&gt;&lt;P&gt;&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&amp;nbsp; );&lt;/P&gt;&lt;P&gt;);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;);&lt;/P&gt;&lt;P&gt;);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS:&amp;nbsp; I can get the correct answer when run the code without change the value in the slice column, but I cannot update X columns if I change the value of slice. Note that the number of X columns is the maximum value in the slice column, which is not fixed with different values. In following pictures, I show the examples to select column 1 and column 2 in the test data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Pulong&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Mar 2015 14:53:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-formula-to-generate-columns-of-design-matrix/m-p/11507#M11027</guid>
      <dc:creator>pulong</dc:creator>
      <dc:date>2015-03-19T14:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: create formula to generate columns of design matrix</title>
      <link>https://community.jmp.com/t5/Discussions/create-formula-to-generate-columns-of-design-matrix/m-p/11508#M11028</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I wasn't quite sure exactly what you were looking for. But given you are new to JMP, the code below may give you some ideas.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #032ce4;"&gt;NamesDefaultToHere&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #008f00;"&gt;// Test table&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #032ce4;"&gt;&lt;SPAN style="color: #000000;"&gt;dt &lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;NewTable&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #942193;"&gt;"Test"&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&amp;nbsp; &lt;SPAN style="color: #032ce4;"&gt;NewColumn&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;SPAN style="color: #942193;"&gt;"C1"&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt; Numeric&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt; Continuous&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt; Formula&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;SPAN style="color: #032ce4;"&gt;RandomInteger&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;5&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt;)))&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&amp;nbsp; &lt;SPAN style="color: #032ce4;"&gt;NewColumn&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;SPAN style="color: #942193;"&gt;"C2"&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt; Numeric&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt; Continuous&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt; Formula&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;SPAN style="color: #032ce4;"&gt;RandomInteger&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;5&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt;)))&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&amp;nbsp; &lt;SPAN style="color: #032ce4;"&gt;NewColumn&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;SPAN style="color: #942193;"&gt;"C3"&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt; Numeric&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt; Continuous&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt; Formula&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;SPAN style="color: #032ce4;"&gt;RandomInteger&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;5&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt;)))&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&amp;nbsp; AddRows&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;10&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&amp;nbsp; &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #008f00;"&gt;// UI&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #942193;"&gt;&lt;SPAN style="color: #032ce4;"&gt;NewWindow&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;/SPAN&gt;"Update Design"&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #942193;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #032ce4;"&gt;PanelBox&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;/SPAN&gt;"Pick a columnn to see the design"&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #032ce4;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; lub &lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;LineUpBox&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;/SPAN&gt;NCol&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&amp;nbsp; clb &lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="color: #032ce4;"&gt;ColListBox&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;dt&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt; All&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt; Numeric&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt; MaxItems&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt; MinItems&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt; clbScript&lt;STRONG&gt;)&lt;/STRONG&gt;&amp;nbsp; &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&amp;nbsp; &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&amp;nbsp; &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #008f00;"&gt;// Script to dynamically update the line up box lb depending on the selection in clb&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;clbScript &lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #032ce4;"&gt;Expr&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #008f00;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; &lt;/SPAN&gt;// Get the values in the selected column&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #011993;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; vals &lt;/SPAN&gt;=&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #032ce4;"&gt;Column&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;dt&lt;/SPAN&gt;,&lt;SPAN style="color: #000000;"&gt; clb &lt;/SPAN&gt;&amp;lt;&amp;lt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;getSelected&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;)&lt;/STRONG&gt; &lt;/SPAN&gt;&amp;lt;&amp;lt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;getAsMatrix&lt;/STRONG&gt;;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #008f00;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; &lt;/SPAN&gt;// Delete any existing matrix box&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #011993;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #032ce4;"&gt;Try&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;mb &lt;/SPAN&gt;&amp;lt;&amp;lt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;delete&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #008f00;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; &lt;/SPAN&gt;// Get the design matrix in a matrix box&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #032ce4;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; mb &lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;MatrixBox&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;/SPAN&gt;Design&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;vals&lt;STRONG&gt;))&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #008f00;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; &lt;/SPAN&gt;// Append the new matrix box&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&amp;nbsp; lub &lt;SPAN style="color: #011993;"&gt;&amp;lt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;append&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;mb&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Mar 2015 11:04:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-formula-to-generate-columns-of-design-matrix/m-p/11508#M11028</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2015-03-20T11:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: create formula to generate columns of design matrix</title>
      <link>https://community.jmp.com/t5/Discussions/create-formula-to-generate-columns-of-design-matrix/m-p/11509#M11029</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #555555; background-color: #f2f2f2;"&gt;Thanks for your kind help.&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #555555; background-color: #f2f2f2;"&gt;I need to generate design matrix from a column, so that I can also update the design matrix if the values in the column are changed. In fact, I want to create a formula to generate the design matrix based on selected columns, and save the formula so that I can update the design matrix if some values in the selected columns are modified.&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #555555; background-color: #f2f2f2;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #555555; background-color: #f2f2f2;"&gt;In my code, the design matrix is generated, but I cannot get the updated design matrix if I change certain value in the selected column, which is the problem I am struggling with. I really appreciated it if you could provide some suggestion on my problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #555555; background-color: #f2f2f2;"&gt;Thanks,&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #555555; background-color: #f2f2f2;"&gt;Pulong&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Mar 2015 17:33:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-formula-to-generate-columns-of-design-matrix/m-p/11509#M11029</guid>
      <dc:creator>pulong</dc:creator>
      <dc:date>2015-03-31T17:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: create formula to generate columns of design matrix</title>
      <link>https://community.jmp.com/t5/Discussions/create-formula-to-generate-columns-of-design-matrix/m-p/11510#M11030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I could certainly be wrong (depending on how general you need your solution to be), but it doesn't feel to me that formula columns are the best way to attempt this. The fact that one column in your source table (generally) maps to multiple columns, and the fact that the number of such columns is the (variable) number of levels in the source column make this difficult.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Before offering another suggestion, perhaps you could describe the workflow you envisage in a little more detail, please? Also indicate which steps involve manual intervention.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Apr 2015 09:57:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-formula-to-generate-columns-of-design-matrix/m-p/11510#M11030</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2015-04-01T09:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: create formula to generate columns of design matrix</title>
      <link>https://community.jmp.com/t5/Discussions/create-formula-to-generate-columns-of-design-matrix/m-p/11511#M11031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since this is the first time to use JMP, I will try to describe my problem in the language of JMP script. Briefly, I have a data table, within which, there exist a "slice" column, and I want to generate the design matrix based on the slice column, and also generate some other columns based on the design matrix. What I need to do is to develop a JMP add-in which implements this task, so that other colleagues can also use my add-in for computer experiments.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First, I would like to develop a window to select the slice column, and generate a data table including the slice column and the design matrix, and save the formula &lt;SPAN style="font-size: 13.3333330154419px;"&gt;to automatically update the design matrix if some values in the slice column are changed later&lt;/SPAN&gt;. ( I need to save formula , because my project manager requested it, but I could convince him without using the formula columns if I come up with a better solution.)&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, I can create the window, and generate the data table which includes the sliced column and design matrix, but the design matrix cannot be updated if I change the values in the slice column.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding the sliced column:&lt;/P&gt;&lt;P&gt;I know that the design function in JMP can automatically generate the design matrix, but it's not helpful if I want&amp;nbsp; formula columns. So I wrote my own function to generate my design matrix, as shown in my script. Suppose that I have the slice column a = [1, 1, 2, 3]'. Then the design matrix will be generated as &lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.&lt;/P&gt;&lt;P&gt;The sliced column can be vary large, and hence it's difficult to know how many columns will the design matrix have by manually looking at the slice column. Besides, the values in the sliced column can be modified arbitrarily. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think the key steps to create generate the design matrix are the following:&lt;/P&gt;&lt;P&gt;1. select the sliced column, click the button "OK", then a new table will be generated, which includes the slice column and design matrix. Clearly, this step involves manually intervention.&lt;/P&gt;&lt;P&gt;2. If I modify some values in the slice column in the new table manually, then the original design matrix will be deleted automatically, and the corresponding new design matrix will be generated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Second, I also need to generate some columns based on the design matrix, and I also wrote out the script to generate them, but I do not know how to save them as formula columns. This issue will not be a problem if I know how to save the formula columns for design matrix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Last, if I succeeded to create the design matrix and some columns, then I would package them as a add-in, and test it under many different circumstance. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your suggestion. Let me know if I make myself understood.&lt;/P&gt;&lt;P&gt;Pulong&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Apr 2015 13:25:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-formula-to-generate-columns-of-design-matrix/m-p/11511#M11031</guid>
      <dc:creator>pulong</dc:creator>
      <dc:date>2015-04-02T13:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: create formula to generate columns of design matrix</title>
      <link>https://community.jmp.com/t5/Discussions/create-formula-to-generate-columns-of-design-matrix/m-p/11512#M11032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Many thanks for your more detailed explanation. Perhaps I can echo it back in different words to be sure I have understood?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Suppose the first table (containing all possible slices) is called dt0. Thinking about your key steps above:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;The user selects a column (a slice) in dt0, and makes a new table (call this dt1) containing just this slice, plus the columns of the design matrix (plus the other derived columns you mention, but don't spell out).&lt;/LI&gt;&lt;LI&gt;You want the user to later be able to modify the slice column in dt1 and have the other columns in dt1 update 'automatically'.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I imagine that you final add-in would have two menu options: 'Define Slice' and 'Update Slice'. If my description of 1. above is correct, this 'Design Slice' script is easily obtained by tweaking the code I've already suggested: The table dt1 could be put in a shared folder so others could get it, and you can add whatever metadata you want to the table or the columns within it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The 'Update Slice' script could present the user with all the available tables in the shared folder, and allow them to select one. At this point, though, they would not edit the table directly: Rather they would be presented with a report window allowing them to modify the values of the slice column in the table. Here, 'modify' could mean update existing values, or append new rows. When they click OK in this report to signify they are happy, dt1 could be automatically updated to reflect all their changes, and you could also update the metadata as required. Of course this 'update' code would be common with 'Define Slice'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unless I've misunderstood, it seems that this workflow would be reasonable, perhaps even better than giving users free access to dt1 itself.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Apr 2015 16:17:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-formula-to-generate-columns-of-design-matrix/m-p/11512#M11032</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2015-04-02T16:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: create formula to generate columns of design matrix</title>
      <link>https://community.jmp.com/t5/Discussions/create-formula-to-generate-columns-of-design-matrix/m-p/11513#M11033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for you reply. &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Your understanding about the workflow is precisely what I am doing. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regard "Define Slice":&lt;/P&gt;&lt;P&gt;I have already designed the window to achieve this task. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regard "Update Slice":&lt;/P&gt;&lt;P&gt;The difficulty lies in the automatic update to whatever change the user will make. I can generate the design matrix, but I do not know how to automatically update the design matrix if the user makes some change in slice column. Besides, if I know how to automatically update the design matrix, it will not be a problem to automatically generate other columns based on the design matrix by tweaking the code a little bit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Pulong&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Apr 2015 19:31:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-formula-to-generate-columns-of-design-matrix/m-p/11513#M11033</guid>
      <dc:creator>pulong</dc:creator>
      <dc:date>2015-04-02T19:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: create formula to generate columns of design matrix</title>
      <link>https://community.jmp.com/t5/Discussions/create-formula-to-generate-columns-of-design-matrix/m-p/11514#M11034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, many thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So it sounds like the missing piece is to be able to edit the cells of a (numeric) column in a report window, in which case you can use 'NumberColEditBox()'. For a character column you can use 'StringColEditBox'. By combining the two you could present any table in an editor window that your code controls (though I guess you would need to skip row state and expression columns):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #032ce4;"&gt;NamesDefaultToHere&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #008f00;"&gt;// Use a numeric column&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #942193;"&gt;&lt;SPAN style="color: #000000;"&gt;dt &lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #032ce4;"&gt;Open&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;/SPAN&gt;"$SAMPLE_DATA/Big Class.JMP"&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #942193;"&gt;&lt;SPAN style="color: #000000;"&gt;cName &lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;"height"&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;cVals &lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="color: #032ce4;"&gt;Column&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;dt&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt; cName&lt;STRONG&gt;)&lt;/STRONG&gt; &lt;SPAN style="color: #011993;"&gt;&amp;lt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;getValues&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #008f00;"&gt;// UI&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;nw &lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="color: #032ce4;"&gt;NewWindow&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;SPAN style="color: #942193;"&gt;"Edit Cells"&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt; ceb &lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="color: #032ce4;"&gt;NumberColEditBox&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;cName&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt; cVals&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt; &lt;SPAN style="color: #032ce4;"&gt;ButtonBox&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;SPAN style="color: #942193;"&gt;"Update"&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt; updateCells&lt;STRONG&gt;))&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #008f00;"&gt;// Update script&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;updateCells &lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #032ce4;"&gt;Expr&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #011993;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; nw &lt;/SPAN&gt;&amp;lt;&amp;lt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;closeWindow&lt;/STRONG&gt;;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&amp;nbsp; newVals &lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt; ceb &lt;SPAN style="color: #011993;"&gt;&amp;lt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;getAsMatrix&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #011993;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; dt &lt;/SPAN&gt;&amp;lt;&amp;lt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;BeginDataUpdate&lt;/STRONG&gt;;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&amp;nbsp; &lt;SPAN style="color: #032ce4;"&gt;Column&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;dt&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt; cName&lt;STRONG&gt;)&lt;/STRONG&gt; &lt;SPAN style="color: #011993;"&gt;&amp;lt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;setValues&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;newVals&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #011993;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; dt &lt;/SPAN&gt;&amp;lt;&amp;lt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;EndDataUpdate&lt;/STRONG&gt;;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Apr 2015 09:56:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-formula-to-generate-columns-of-design-matrix/m-p/11514#M11034</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2015-04-03T09:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: create formula to generate columns of design matrix</title>
      <link>https://community.jmp.com/t5/Discussions/create-formula-to-generate-columns-of-design-matrix/m-p/11515#M11035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;I really appreciate for your help.&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;I have already figured out a solution to my problem today.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2015 19:13:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-formula-to-generate-columns-of-design-matrix/m-p/11515#M11035</guid>
      <dc:creator>pulong</dc:creator>
      <dc:date>2015-04-07T19:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: create formula to generate columns of design matrix</title>
      <link>https://community.jmp.com/t5/Discussions/create-formula-to-generate-columns-of-design-matrix/m-p/209807#M42063</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I have a similar -if not identical- question.&lt;/P&gt;&lt;P&gt;I want to create a design matrix from predictor variables similar to x2fx in Matlab.&lt;/P&gt;&lt;P&gt;For example: by selecting predictor variables &amp;amp; specify the designtype (2nd order interactions) and then generate the design table.&lt;/P&gt;&lt;P&gt;See example from Matlab below: (but I want to do this in JMP).&lt;/P&gt;&lt;P&gt;Example 1&lt;/P&gt;&lt;P&gt;The following converts 2 predictors &lt;CODE class="literal"&gt;&lt;FONT face="Courier New" size="3"&gt;X1&lt;/FONT&gt;&lt;/CODE&gt; and &lt;CODE class="literal"&gt;&lt;FONT face="Courier New" size="3"&gt;X2&lt;/FONT&gt;&lt;/CODE&gt; (the columns of &lt;CODE class="literal"&gt;&lt;FONT face="Courier New" size="3"&gt;X&lt;/FONT&gt;&lt;/CODE&gt;) into a design matrix for a full quadratic model with terms &lt;CODE class="literal"&gt;&lt;FONT face="Courier New" size="3"&gt;constant&lt;/FONT&gt;&lt;/CODE&gt;, &lt;CODE class="literal"&gt;&lt;FONT face="Courier New" size="3"&gt;X1&lt;/FONT&gt;&lt;/CODE&gt;, &lt;CODE class="literal"&gt;&lt;FONT face="Courier New" size="3"&gt;X2&lt;/FONT&gt;&lt;/CODE&gt;, &lt;CODE class="literal"&gt;&lt;FONT face="Courier New" size="3"&gt;X1.*X2&lt;/FONT&gt;&lt;/CODE&gt;, &lt;CODE class="literal"&gt;&lt;FONT face="Courier New" size="3"&gt;X1.^2&lt;/FONT&gt;&lt;/CODE&gt;, and &lt;CODE class="literal"&gt;&lt;FONT face="Courier New" size="3"&gt;X2.^2&lt;/FONT&gt;&lt;/CODE&gt;.&lt;/P&gt;&lt;DIV class="code_responsive"&gt;&lt;PRE class="programlisting"&gt;X = [1 10
     2 20
     3 10
     4 20
     5 15
     6 15];

D = x2fx(X,'quadratic')
D =
     1     1    10    10     1   100
     1     2    20    40     4   400
     1     3    10    30     9   100
     1     4    20    80    16   400
     1     5    15    75    25   225
     1     6    15    90    36   225&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 22 May 2019 12:01:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-formula-to-generate-columns-of-design-matrix/m-p/209807#M42063</guid>
      <dc:creator>Eduard-Derks</dc:creator>
      <dc:date>2019-05-22T12:01:53Z</dc:date>
    </item>
    <item>
      <title>Re: create formula to generate columns of design matrix</title>
      <link>https://community.jmp.com/t5/Discussions/create-formula-to-generate-columns-of-design-matrix/m-p/209836#M42072</link>
      <description>&lt;P&gt;Please see Help &amp;gt; Scripting Index. Change the browser to show Functions. Then select the Matrix group of functions. You will find here several functions to make the model matrix (for terms) from the design matrix (factor levels).&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2019 14:47:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-formula-to-generate-columns-of-design-matrix/m-p/209836#M42072</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2019-05-22T14:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: create formula to generate columns of design matrix</title>
      <link>https://community.jmp.com/t5/Discussions/create-formula-to-generate-columns-of-design-matrix/m-p/209839#M42074</link>
      <description>&lt;P&gt;My apologies. I read your request again and realized that none of the JSL functions will help in this case. They are intended to create the columns for the effects of categorical factors for the linear regression.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a script that will take the matrix with the factor levels and create the matrix with a column for each term in a quadratic polynomial:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here( 1 );

x2fx = Function( { x }, { n factors, n treat, fx, f, f1, f2 },
	n factors = N Col( x );
	n treat = N Row( x );
	fx = J( n treat, 1, 1 );
	For( f = 1, f &amp;lt;= n factors, f++,
		fx ||= x[0,f];
	);
	For( f1 = 1, f1 &amp;lt; n factors, f1++,
		For( f2 = f1+1, f2 &amp;lt;= n factors, f2++,
			fx ||= x[0,f1] :* x[0,f2];
		);
	);
	For( f = 1, f &amp;lt;= n factors, f++,
		fx ||= x[0,f]^2;
	);
	fx;
);

X = [1 10,
     2 20,
     3 10,
     4 20,
     5 15,
     6 15];

D = x2fx( X );

Show( D );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It is not that hard to make your own functions.&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2019 15:02:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-formula-to-generate-columns-of-design-matrix/m-p/209839#M42074</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2019-05-22T15:02:23Z</dc:date>
    </item>
  </channel>
</rss>

