從線性擬合常數(斜率、截距)創建列嘗試從多個圖中的線性擬合公式中提取常數、斜率和截距。我以大班為例。我製作了跨不同參數的雙變量圖,接下來我對每個圖進行線性擬合併為預測值創建一個新列。我想採用線性擬合公式常量並創建兩個新列,用於保存每行該公式的斜率和截距。 這是我到目前為止所擁有的,我被困在保存線性擬合公式的地方,但無法完全將公式值拉入列中,我想我想使用 expr() 函數,但我不確定,任何幫助將不勝感激,提前致謝。
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 << (curve[1] << save predicteds);
Column( N Cols( dt ) ) << set name( "Linear Fit" );
myFormula = Column(dt, "Linear Fit") << 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 << NewColumn("Slope", Numeric, Continous, expr(left(myFormula,5)));
dt << NewColumn("Intercept", Numeric, Continous, );
回复:從線性擬合常數創建列(斜率、截距)我喜歡數據表處理,所以很多時候我使用“創建組合數據表”,然後從那裡開始。這是腳本的一個版本,我認為您最終想要的輸出是
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)]<<MAKE combined="" data="https://community.jmp.com/" table=""></MAKE>回复:從線性擬合常數創建列(斜率、截距)吉姆,
我考慮過這一點,但我失去了與原始大類數據集(即“名稱”)的聯繫,我想返回並連接兩個表也很容易,而不是試圖在一個表中變得太花哨。謝謝!
回复:從線性擬合常數創建列(斜率、截距)我相信,如果您從估計表中創建組合數據表,您將可以更輕鬆地從性別和年齡的所有不同組合中獲取斜率和截距值。它將允許您解析輸出的數據表並輕鬆獲得您想要的值。
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)]<<MAKE combined="" data="https://community.jmp.com/" table=""></MAKE>