RfastOfficial / Rfast

A collection of Rfast functions for data analysis. Note 1: The vast majority of the functions accept matrices only, not data.frames. Note 2: Do not have matrices or vectors with have missing data (i.e NAs). We do no check about them and C++ internally transforms them into zeros (0), so you may get wrong results. Note 3: In general, make sure you give the correct input, in order to get the correct output. We do no checks and this is one of the many reasons we are fast.
139 stars 19 forks source link

Missing `intercept` value in fitting Linear Regression using `lmfit` #101

Closed luna02100 closed 1 month ago

luna02100 commented 4 months ago

When I fit a linear regression using lmfit, I noticed that there is a missing component, and that is the intercept of the linear model.

> Rfast::lmfit(x = as.matrix(cbind(x1,x2)),y = y)
$be
       [,1]
x1 1.987387
x2 2.977526
attr(,"names")
[1] "x1" "x2"

While fitting a linear regression using base R:

> form_ex
y ~ x1 + x2

> lm(form_ex)

Call:
lm(formula = form_ex)

Coefficients:
(Intercept)           x1           x2  
     0.1084       1.9732       2.9806  
statlink commented 4 months ago

Hi Joshbal, you are suppose to provide the design matrix. This function is similar R's .lm.fit() function.

luna02100 commented 1 month ago

Hi, one-winged here. I know it's

luna02100 commented 1 month ago

Hi, one-winged here. It's been 3 months since I create this issue. Yeah, it turns out that I entered the data wrong.

luna02100 commented 1 month ago

I request to delete this issue if you may.