在R(终端)和Rstudio中使用lm()可以提供具有相同输入数据的不同输出

时间:2019-07-19 14:01:36

标签: r

我正在拟合一个线性模型,对于该模型,我根据使用RStudio还是R获得不同的系数;即使我在两种情况下都使用相同的输入数据和相同的代码。

我尝试了数据的不同子集(从仅10行到最多一半的数据),并且差异仅在输入整个数据集时发生。

Here's the dput() output(太大了,无法粘贴到这里,密码:r)

a = dputdata
lm.transcprot = lm(formula = I(a$b - 0) ~ 0 + a$a)

会话详细信息:

RStudio

> sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 9 (stretch)

Matrix products: default
BLAS/LAPACK: /usr/lib/libopenblasp-r0.2.19.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=C             
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_3.6.0   rsconnect_0.8.13 tools_3.6.0    

> find('lm')
[1] "package:stats"

> summary(a)
        a                 b   
 Min.   :  1.002   Min.   :     0.13   
 1st Qu.:  5.887   1st Qu.:  5320.27   
 Median : 14.551   Median : 11739.61   
 Mean   : 25.877   Mean   : 20524.21                     
 3rd Qu.: 34.424   3rd Qu.: 26430.47                     
 Max.   :136.997   Max.   :116315.41  

端子

> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.2 LTS

Matrix products: default
BLAS/LAPACK: /opt/intel/compilers_and_libraries_2019.3.199/linux/mkl/lib/intel64_lin/libmkl_rt.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_3.6.1 tools_3.6.1   

> find('lm')
[1] "package:stats"

> summary(a)
        a                 b   
 Min.   :  1.002   Min.   :     0.13   
 1st Qu.:  5.887   1st Qu.:  5320.27   
 Median : 14.551   Median : 11739.61   
 Mean   : 25.877   Mean   : 20524.21                     
 3rd Qu.: 34.424   3rd Qu.: 26430.47                     
 Max.   :136.997   Max.   :116315.41

获得的输出:

RStudio

> lm.transcprot

Call:
lm(formula = I(a$b - 0) ~ 0 + a$a)

Coefficients:
a$a  
    462.5  

端子

> lm.transcprot            

Call:
lm(formula = I(a$b - 0) ~ 0 + a$a)

Coefficients:
a$a  
     1889

0 个答案:

没有答案