Linear model singular because of large integer datetime in R?

前端 未结 1 1186
滥情空心
滥情空心 2021-01-23 23:07

Simple regression of random normal on date fails, but identical data with small integers instead of dates works as expected.

# Example dataset with 100 observati         


        
相关标签:
1条回答
  • 2021-01-23 23:45

    Yes, it could. QR factorization is stable, but is not almighty God.

    X <- cbind(1, 1e+11 + 1:10000)
    qr(X)$rank
    # 1
    

    Here the X is like the model matrix for your linear regression model, where there is a all-1 column for intercept, and there is a sequence for datetime (note the large offset).

    If you center the datetime column, these two columns will be orthogonal hence very stable (even when solving normal equation directly!).

    0 讨论(0)
提交回复
热议问题