Last active
November 9, 2017 09:02
-
-
Save mbk0asis/ecba8a1c62f866b62d54d5467eb06d1f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# drawing a scatter plot and regression line | |
# draw a scatter plot | |
library(LSD) | |
heatscatter( dta$a, dta$b, cor = TRUE, method = "pearson" ) | |
# add regression line | |
abline( lm( dta$b ~ dta$a ) ) # switch columns (a<-->b) | |
# FYI of linear modeling | |
lmodel <- lm( dta$b ~ dta$a ) # linear modeling | |
summary( lmodel ) # just looking at the results | |
coef( lmodel ) | |
intcp <- coef(lmodel)[1] # extract intercept value | |
slp <- coef(lmodel)[2] # extract slope value | |
abline(intcp, slp) # draw regression line using slope and intercept values | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment