@Jeff_Perkinson , @Milo ,
这是参考讨论 - 斜率和截距函数
我发现这个讨论很有帮助。我目前正在使用JMP 13,所以如果在JMP 14中进行了开发,我不一定能够访问它。
但是,这是我的问题:
Clear Log() ; Clear Globals(); Close All(DataTables,"No Save");
Slope = function({x,y},{default local},
If( !(Is Matrix( x ) & Is Matrix( y ) & N Col( x ) == 1 & N Col( y ) == 1),
Show( "x or y arguments are not matrices or they have more than one column" );
Throw();
,
x = J( N Row( x ), 1 ) || x; // put in an intercept column of 1s
beta = Inv( X` * X ) * X` * Y; // the least square estimates
beta[2];
);
);
Intercept = function({x,y},{default local},
If( !(Is Matrix( x ) & Is Matrix( y ) & N Col( x ) == 1 & N Col( y ) == 1),
Show( "x or y arguments are not matrices or they have more than one column" );
Throw();
,
x = J( N Row( x ), 1 ) || x; // put in an intercept column of 1s
beta = Inv( X` * X ) * X` * Y; // the least square estimates
beta[1];
);
); // end of intercept function
x1 = 0.05417099;
x2 = 0.057730865;
y1 = 30.5885;
y2 = 31.5885;
dt = New Table();
dt << New Column("X",Numeric,Continuous,<< Set Values({x1,x2}))
<< New Column("Y",Numeric,Continuous,<< Set Values({y1,y2}));
dt << New Script("Biv",Bivariate( Y( :Y ), X( :X ), Fit Line( {Line Color( {213, 72, 87} )} ) ));
SlopeTest = Slope(Matrix({y1,y2}),Matrix({x1,x2}));
Show(SlopeTest);
InterceptTest = Intercept(Matrix({y1,y2}),Matrix({x1,x2}));
Show(InterceptTest);
1。为什么斜率和截距与我采用双变量的测试用例不匹配?
2。如果函数或其实现有错误,您是否愿意提供替代方案?
您输入的顺序是向后的。 在函数上它是斜率(x,y),当你打电话给你做斜率(y,x)
@cwillden ,
虽然这是一个很好的捕获,但并没有改变结果,功能与二变量不匹配
你得到了Slope and Intercept函数的后向参数。 只需颠倒矩阵的顺序即可。