Advertisement
Guest User

Simple linear regression

a guest
Nov 20th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.25 KB | None | 0 0
  1. > # Input data
  2. > head(my_df)
  3.                Y            X
  4. [1,] -0.39643897  0.014797410
  5. [2,] -1.11042940 -1.634525956
  6. [3,] -0.02086076 -0.340575102
  7. [4,]  1.90382401  0.117504381
  8. [5,]  0.62557591  1.042435648
  9. [6,] -1.40269719 -0.006455178
  10. > dimmy_df
  11. dim                    dim.data.frame         dim<-                  dimnames               dimnames.data.frame    dimnames<-             dimnames<-.data.frame  
  12. > dim(my_df)
  13. [1] 50  2
  14.  
  15. ######
  16.  
  17. > lm(data=my_df, " Y ~ X ")
  18.  
  19. Call:
  20. lm(formula = " Y ~ X ", data = my_df)
  21.  
  22. Coefficients:
  23. (Intercept)            X  
  24.  -1.076e-17    5.600e-01  
  25.  
  26. > model = lm(data=my_df, " Y ~ X ")
  27. > summary(model)
  28.  
  29. Call:
  30. lm(formula = " Y ~ X ", data = my_df)
  31.  
  32. Residuals:
  33.      Min       1Q   Median       3Q      Max
  34. -1.65443 -0.57053 -0.06958  0.47720  1.83802
  35.  
  36. Coefficients:
  37.               Estimate Std. Error t value Pr(>|t|)    
  38. (Intercept) -1.076e-17  1.184e-01   0.000        1    
  39. X            5.600e-01  1.196e-01   4.683 2.35e-05 ***
  40. ---
  41. Signif. codes:  0***0.001**0.01*0.05 ‘.’ 0.1 ‘ ’ 1
  42.  
  43. Residual standard error: 0.8371 on 48 degrees of freedom
  44. Multiple R-squared:  0.3136,    Adjusted R-squared:  0.2993
  45. F-statistic: 21.93 on 1 and 48 DF,  p-value: 2.352e-05
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement