回复:嘗試編寫腳本來比較未來的預測值如果有幫助......
我的數據表設置如下:
日期時間 log_turb_pear millsR_Q_lag_6hrs pred 公式 log_ecoli_pear(計算)
01/04/2021 08:00 上午 1.32 50 2.64
01/04/2021 08:15 上午 1.46 45 2.72
01/04/2021 08:30 上午 1.59 50 2.90
01/04/2021 08:45 上午 2.20 50 3.7
01/04/2021 09:00 上午 2.25 58 3.19
等等
我試圖將 :pred 公式 log_ecoli_pred 在 1/4/2021, 8 am(即 2.64)的值與直到 01/12/21 上午 7:45 的所有其他時間獲得的值進行比較。然後我需要計算每個值是 + 或 - 2.64 的 25% 的次數。然後在下一周重複,依此類推,直到數據表中的所有周都進行了計數。(注意,如果需要的話,2019年的第一個星期一是1月7日,2020年的第一個星期一是1月6日,2021年的第一個星期一是1月4日……我的數據表有從2019年初到現在的記錄。 ) 上例表中只有一個值 (3.7) 大於 2.64 的 + 或 - 25%(即 <(0.75 * 2.64) 或 > (1.25 * 2.64))。
回复:嘗試編寫腳本來比較未來的預測值為簡單起見,我的問題實際上歸結為:我將如何從即將到來的行中檢索/讀取列值(我將其稱為第 n+1 行),對其進行計算,然後從之後的行中檢索(n+2) 並進行計算,依此類推,直到我到達第 n=672 行(這是 7 天的 15 分鐘增量)......然後重新開始從第 n=672 行開始進行新的計算並為接下來的 672 行繼續相同的循環工作流.....然後在 n = 672 +672 = 1344 處再次開始......依此類推,直到我用完數據表中的行。如果需要,我很樂意澄清。即使是一個提示也可能讓我走上正軌。提前致謝!
嘗試編寫腳本來比較未來的預測值大家好 - 我仍在學習 JSL 的基礎知識,並且正在嘗試編寫一個腳本來比較“時間點”預測值與接下來 7 天內的後續預測值的比較情況。我試圖讓腳本執行以下操作:
1 - 對數據表中的所有行執行回歸(每行對應 15 分鐘的增量,因此我的預測值每 15 分鐘計算一次)。
前任:
obj = Fit Model(
Y( :LOG_ECOLI_Pear ),
Effects( :LOG_TURB_Pear, :millsR_Q_lag6hr ),
Personality( "Standard Least Squares" ),
Emphasis( "Effect Leverage" ),
Run( :LOG_ECOLI_Pear )
);
obj << Prediction Formula;
2 - 在跨越 3 年的整個數據集中選擇每週一早上 8 點發生的預測值。
3 - 將該值與在該上午 8 點值之後的一周內發生的所有其他預測值(即周一上午 8:15 到下週一上午 7:45)進行比較。(也就是說,一周內計算的所有值都將與星期一上午 8 點的值進行比較。)然後,計算所有這些預測值都超過上午 8 點值的 + 或 - 25% 的行數那一周。繼續(重複這個過程)直到所有的周都被計算在內。
前任:
New Column( "count num above or below 25pct of mon 8am",
numeric,
continuous,
formula(
If( Row() == 1, x = 0 );
((If( :above or below 25pct of mon 8am == 1,
x = x + :above or below 25pct of mon 8am,
X = X + :above or below 25pct of mon 8am
)));
x;
)
);
我不知道如何選擇一周的值來與週一上午 8 點的值進行比較。而且我不確定我是否在正確的軌道上。我將不勝感激任何幫助!
腳本編寫回复:嘗試編寫腳本來比較未來的預測值你好@learning_JSL ,
以下是一些幫助您入門的想法;代碼未測試。
//Set Initial Constraints
strt_row = 1;
end_row = 672;
ref_col_name = "pred formula log_ecoli_pear";
dt = Data Table( "community_post.jmp" );
cnt_ref = 0;
cnt_ref_2 = 0;
//Create Loop
for(r = 1, r <= NRows(dt), r++,
//find begin date
mod_strt_row = Modulo( dt:datetime[r], dt:datetime[1] );
If(mod_strt_row == 0, strt_row = row() );
//find end date
mod_end_row = Modulo( row(), end_row );
If(mod_end_row == 0, end_row = row() );
If(r == strt_row,
//get reference times and value for start row and column
ref_strt_time_value = dt:datetime[strt_row];
ref_col_name_value = Column(dt, ref_col_name)[strt_row];
show( format(ref_strt_time_value, "m/d/y h:m", 19), ref_col_name_value )
,
r!=end_row & r > 1,
row() = r;
compare_value = Lag( Column(dt,ref_col_name)[], 1);
low_limit_ref_value = 0.75*ref_col_name_value;
upper_limit_ref_value = 1.25*ref_col_name_value;
calc_val = Abs( ( ( ref_col_name_value - compare_value ) / ref_col_name_value ) * 100);
If(ref_col_name_value >= low_limit_ref_value | ref_col_name_value <= upper_limit_ref_value,
cnt_ref_2 = cnt_ref_2 + 1;
show( calc_val, cnt_ref_2);
);
If( calc_val <= 25,
cnt_ref = cnt_ref+1;
show(calc_val, cnt_ref);
);
,
r == end_row,
ref_end_time_value = dt:datetime[end_row];
show(format(ref_end_time_value, "m/d/y h:m", 19) );
);
);
cnt_ref_2;
cnt_ref;
回复:嘗試編寫腳本來比較未來的預測值謝謝斯坦。我會試試這個。