Skip to content

Instantly share code, notes, and snippets.

@dr-kd
Created September 27, 2010 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dr-kd/598933 to your computer and use it in GitHub Desktop.
Save dr-kd/598933 to your computer and use it in GitHub Desktop.
> pop <- read.csv('popdensitygraph.csv')
> names(pop)
[1] "X" "Y"
> summary(lm(pop$X~pop$Y))
Call:
lm(formula = pop$X ~ pop$Y)
Residuals:
Min 1Q Median 3Q Max
-0.54671 -0.17203 0.03501 0.14217 0.74129
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.21719 0.01904 11.41 < 2e-16 ***
pop$Y 0.77381 0.19106 4.05 7.3e-05 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.2521 on 202 degrees of freedom
Multiple R-squared: 0.07511, Adjusted R-squared: 0.07053
F-statistic: 16.4 on 1 and 202 DF, p-value: 7.295e-05
> cor.test(pop$X,pop$Y)
Pearson's product-moment correlation
data: pop$X and pop$Y
t = 4.0501, df = 202, p-value = 7.295e-05
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.1420327 0.3965006
sample estimates:
cor
0.2740567
> c(0.1420327, 0.3965006) ^2
[1] 0.02017329 0.15721273
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment