0

我有一个用 IDL 编写的代码,我想将其转换为 R。

在代码中我发现了这个函数:

result  = linfit(dum_x, dum_y) 
 y_a= result[0]
 y_b= result[1]
           "LINFIT function" which fits the paired data { xi , yi } to the linear model, y = A + Bx, 
               by minimizing the Chi-square error statistic

我想知道R中是否有类似的功能?任何想法我们如何将此行转换为 R :

       y_a= result[0]   
4

1 回答 1

1

My guess is

result <- lm(dum_y~dum_x)
y_a <- coef(result)[1]
y_b <- coef(result)[2]

but I don't have access to IDL so I can't check ... you could give a reproducible example with IDL/LINFIT results ...

于 2013-08-26T12:31:11.033 回答