20列のデータがあります。 各列を他のすべての列と1つずつ乗算する必要があります。 たとえば、列2 *列3です。列2 *列4。列2 *列5 ...列3 *列4、列3 *列5 ... JMPでこれを行う簡単な方法はありますか?
ご協力いただきありがとうございます、
ジェス
こんにちは @Jess 、
私は対話的に利用できるその種のどんなペアワイズ乗算も知りません、しかしそれはいくつかの簡単なスクリプトで行うことができます。JSLで働いたことはありますか?以下は、最初と最後の列番号を指定できるアプローチの1つです。スクリプトでは、ペアごとの製品列を作成します。JSLを使用したことがない場合は、もう少し詳しく説明します。
dt = Open( "$SAMPLE_DATA\US Demographics.jmp" );
startCol = 5;
endCol = 14;
For( i = startCol, i <= endCol - 1, i++,
For( j = i + 1, j <= endCol, j++,
colName = Eval( :Column( i ) << Get Name ) || " * " || Eval( :Column( j ) << Get Name );
New Column( colName, seteachvalue( :Column( i )[] * :Column( j )[] ) );
)
);
これが役に立つことを願っています!
@julian
nchoosekmatrix()を使って列の組み合わせを取得できます。 (何らかの理由で)数値の行列だけが必要な場合は、すぐに実行できます。
Names Default to Here( 1 );
dt = new table("Test",
add rows(20),
New Column("C", <<SET each="" value=""> 14,
dt << Delete Column(15::ncols(dt));
);
cols_to_multiply = 2::14;
n = nitems(cols_to_multiply);
nck_mat = nchoosekmatrix(n, 2); // this only picks 2 of each combination
// if you just want a matrix
st = HPTime();
dt_mat = dt[0, cols_to_multiply]; //get the values as a matrix
big_mat = dt_mat[0, nck_mat]; // get the combinations of dt values
m_mat = shape(big_mat, nitems(big_mat)/2); // have to shape this to only 2 columns so you can multiply accross
m_mat = shape(m_mat[0, 1] :*</img> m_mat[0, 2], 20); // multiply together then reshape to n rows
tot_mat = HPTime() - st;
//turning it into a data table
st = HPTIme();
nck_cols = shape(cols_to_multiply[nck_mat], nrows(nck_mat), 2);// to get the column names
for(i=1, i<=ncols(m_mat), i++,
col_name = (Column(dt, nck_cols[i, 1]) << Get Name()) || " * " || (Column(dt, nck_cols[i, 2])<< Get name());
New Column(col_name, <<SET values=""></SET></SET>