从线性拟合常数(斜率、截距)创建列尝试从多个图中的线性拟合公式中提取常数、斜率和截距。我以大班为例。我制作了跨不同参数的双变量图,接下来我对每个图进行线性拟合并为预测值创建一个新列。我想采用线性拟合公式常量并创建两个新列,用于保存每行该公式的斜率和截距。 这是我到目前为止所拥有的,我被困在保存线性拟合公式的地方,但无法完全将公式值拉入列中,我想我想使用 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>