0

I have a code written in IDL that I want to convert to R.

within the code I found this function:

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

I wonder if there is a similar function in R? Any ideas How we can convert this line to R :

       y_a= result[0]   
Eric Brown
  • 13,774
  • 7
  • 30
  • 71
sacvf
  • 2,463
  • 5
  • 36
  • 54

1 Answers1

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 ...

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453