重新運行公式的腳本問題我在之前的帖子中問過這個問題,但那是幾週前的事了,所以可能不會被注意到。我懷疑這對這個小組來說是一個簡單的腳本問題。下面是一個腳本(由 frank 捐贈),它成功地運行了逐步回歸的蒙特卡洛模擬。它唯一沒有做的是在進行逐步回歸之前重新計算公式中有隨機數的列數。當我手動單擊表中的紅色箭頭並說“重新運行公式”時,<<重新運行公式命令起作用,但在腳本中它沒有做任何事情。有人可以幫我在 For 循環中的每次迭代之前讓公式重新運行嗎?
我不成功的嘗試是腳本中的第 19 行。謝謝。
Clear Globals();
Clear Log();
Names Default To Here( 1 );
//Define path in and out
Path_in = Pick File( "Select file" );
If( Directory Exists( "$Desktop\Fit_Stepwise" ),
,
Create Directory( "$Desktop\Fit_Stepwise" )
);
Path_out = "$Desktop\Fit_Stepwise\";
//Run Fit model and stepwise after open datatable
dt = Open( Path_in );
For( i = 1, i <= 1000, i++,
dt << Rerun Formulas;
ow = dt << Fit Model(
Y( :Y ),
Effects(
:Column 2 001,
:Column 2 002,
:Column 2 003,
:Column 2 004,
:Column 2 005,
:Column 2 006,
:Column 2 007,
:Column 2 008,
:Column 2 009,
:Column 2 010
),
Personality( "Stepwise" ),
Run,
SendToReport( Dispatch( {}, "Step History", OutlineBox, {Close( 1 )} ) )
);
dt_result = Report( ow )[Outline Box( "Stepwise Fit for Y" )][Outline Box( "Current Estimates" )][Table Box( 1 )] << Make Into Data Table;
dt_result << save( Path_out || Char( i ) || ".csv", "csv" );
ow << close window;
dt_result << Close Window;
);
dt << Close Window;
dt_result = Multiple File Import(
<<SET folder="">F\!"" ) > 0.05 ) ) << Delete Rows;
dt_result << Distribution( Stack( 1 ), Nominal Distribution( Column( :Parameter ), Horizontal Layout( 1 ), Vertical( 0 ) ) );</SET>腳本回复:重新運行公式的腳本問題重新運行公式應該可以工作,也許您需要在某處添加 wait(0) ? 在沒有看到數據表的情況下,很難測試問題可能出在哪裡(行數、列數、複雜的公式、隨機種子由於某種原因沒有改變)。
通過這個簡單的示例,值似乎可以正常更新:
Names Default To Here(1);
dt = New Table("Untitled",
Add Rows(5),
New Column("Column1", Numeric, "Continuous", Format("Best", 12), Formula(Random Normal(1, 1))),
New Column("Column2", Numeric, "Continuous", Format("Best", 12), Formula(Random Normal(2, 1)))
);
For(i = 1, i <= 3, i++,
dt << Rerun Formulas;
Show(dt:Column1 << get as matrix);
Show(dt:Column2 << get as matrix);
fm = dt << Fit Model(
Y(:Column1),
Effects(:Column2),
Personality("Stepwise"),
Run,
SendToReport(Dispatch({}, "Step History", OutlineBox, {Close(1)}))
);
dt_result = Report(fm)[Outline Box("Stepwise Fit for Column1")][Outline Box("Current Estimates")][Table Box(1)] << Make Into Data Table;
fm << close window;
//dt_result << Close Window;
);回复:重新運行公式的腳本問題我已附上文件。看起來我在正確的位置插入了重新運行公式,但它不起作用。等待如何以及去哪裡?
回复:重新運行公式的腳本問題只是為了確保該列將被評估,在 For 循環之前添加這個(如果您使用的是比 JMP16 更早的版本,請將 For Each 更改為 For):
For Each({col_name}, dt << get column names(String),
Column(dt, col_name) << suppress eval(False)
);
在我打開的表格中,公式列的評估被抑制,但它可能只是下載文件的安全功能。
如果你必須添加 wait(0),你可以開始有點過分,幾乎在 for 循環內的每一行之後添加它。 在 JMP 中通常不需要它,但在某些情況下需要它。