0

I have been trying to fit a linear regression on different sets of values and I found something a bit odd. Whenever I try to get a linear regression with the function rxLinMod(), oone of the coefficients gets dropped and whenever I use lm(), this doesn't happen.

The data set that was giving me some trouble is this one:

Dates Values
2020-06-19 5950
2020-06-16 5950

After using rxLinMod, I get this:

rxLinMod(formula = Values ~ Dates, data = temp)


Rows Read: 2, Total Rows Processed: 2, Total Chunk Time: 0.001 seconds 
Computation time: 0.006 seconds.
Call:
rxLinMod(formula = Values ~ Dates, data = temp)

Linear Regression Results for: Values ~ Dates
Data: temp
Dependent variable(s): Values
Total independent variables: 2 (Including number dropped: 1)
Number of valid observations: 2
Number of missing observations: 0 

Coefficients:
                   Values
(Intercept)          5950
Dates             Dropped

Meanwhile, lm() returns this:

 Call:
 lm(formula = Values ~ Dates, data = temp)

 Coefficients:
       (Intercept)              Dates
         5.950e+03         -1.829e-13 

I already made sure that none of the variables are being treated as a factor, Date is of Date class, and Values is a numeric class. I was expecting a slope pretty close to 0. Does anyone have any idea of why is the coefficient being dropped in the first one?

If there is anything else you want to know, feel free to ask.

mfgg1992
  • 1
  • 2
  • 1
    You are fitting a regression on just two observations? – MrFlick Dec 24 '20 at 00:50
  • Yes, this is supposed to be a process that runs over several data sets, some of them have more than 2 points, like hundreds, and in this case it only had two. – mfgg1992 Dec 24 '20 at 00:54
  • 1
    Since this is only available in the Microsoft R client (AFAICT), it's going to be hard to answer this. Maybe (since it's not open source) you could ask Microsoft tech support what's going on ... ? – Ben Bolker Dec 24 '20 at 01:29
  • It would be best to use `dput(temp)` to get a cut-and-pasteable version of your data that can be edited into your question – Ben Bolker Dec 24 '20 at 01:34
  • ..what happens when the Values are not equal? – lptr Dec 24 '20 at 22:11

0 Answers0