This is an old revision of the document!
데이터
DATA for regression analysis |
bankaccount | income | famnum |
6 | 220 | 5 |
5 | 190 | 6 |
7 | 260 | 3 |
7 | 200 | 4 |
8 | 330 | 2 |
10 | 490 | 4 |
8 | 210 | 3 |
11 | 380 | 2 |
9 | 320 | 1 |
9 | 270 | 3 |
datavar <- read.csv("http://commres.net/wiki/_media/regression01-bankaccount.csv")
Enter
Model Summaryb |
Model | R | R Square | Adjusted R Square | Std. Error of the Estimate | Change Statistics | | | | |
| | | | | R Square Change | F Change | df1 | df2 | Sig. F Change |
1 | .893a | .798 | .740 | .930 | .798 | 13.838 | 2 | 7 | .004 |
a. Predictors: (Constant), 가족숫자, 수입 |
b. Dependent Variable: 통장갯수 |
ANOVAa |
Model | | Sum of Squares | df | Mean Square | F | Sig. |
1 | Regression | 23.944 | 2 | 11.972 | 13.838 | .004b |
| Residual | 6.056 | 7 | .865 | | |
| Total | 30.000 | 9 | | | |
a. Dependent Variable: 통장갯수 |
b. Predictors: (Constant), 가족숫자, 수입 |
Coefficientsa |
Model | | Unstandardized Coefficients | | Standardized Coefficients | t | Sig. | Correlations | | |
| | B | Std. Error | Beta | | | Zero-order | Partial | Part |
1 | (Constant) | 6.399 | 1.517 | | 4.220 | .004 | | | |
| 수입 | .012 | .004 | .616 | 3.325 | .013 | .794 | .783 | .565 |
| 가족숫자 | -.545 | .226 | -.446 | -2.406 | .047 | -.692 | -.673 | -.409 |
a. Dependent Variable: 통장갯수 |
$\hat{Y} = 6.399 + .012 X_{1} + -.545 X_{2} $
The below is just an exercise for figuring out the unique part of r2 value for x1 and x2 (수입, 가족수). For more information see part and zero-order relationship: see determining_ivs_role in multiple regression
zero-order | part |
x1 | x2 | x1p | x2p |
.794 | -.692 | .565 | -.409 |
zero-order square | part (in spss) = semipartial (in general) |
x1 sq (x1sq) | x2 sq (x1sq) | x1 part sq (x1psq) | x2 part sq (x1psq) |
.630436 | .478864 | .319225 | .167281 |
a+b / a+b+c+d | b+c / a+b+c+d | a / a+b+c+d | c / a+b+c+d |
x1sq - x1psq ~= x2sq - x2psq
0.311211 ~= 0.311583
Seq.
Model Summaryc |
Model | R | R Square | Adjusted R Square | Std. Error of the Estimate | Change Statistics | | | | |
| | | | | R Square Change | F Change | df1 | df2 | Sig. F Change |
1 | .794a | .631 | .585 | 1.176 | .631 | 13.687 | 1 | 8 | .006 |
2 | .893b | .798 | .740 | .930 | .167 | 5.791 | 1 | 7 | .047 |
a. Predictors: (Constant), 수입 |
b. Predictors: (Constant), 수입, 가족숫자 |
c. Dependent Variable: 통장갯수 |
증가한 r2값에 대한 F-test 결과는 Fdiff=5.791, p = .047 (less than .05)
ANOVAa |
Model | | Sum of Squares | df | Mean Square | F | Sig. |
1 | Regression | 18.934 | 1 | 18.934 | 13.687 | .006b |
| Residual | 11.066 | 8 | 1.383 | | |
| Total | 30.000 | 9 | | | |
2 | Regression | 23.944 | 2 | 11.972 | 13.838 | .004c |
| Residual | 6.056 | 7 | .865 | | |
| Total | 30.000 | 9 | | | |
a. Dependent Variable: 통장갯수 |
b. Predictors: (Constant), 수입 |
c. Predictors: (Constant), 수입, 가족숫자 |
Coefficientsa |
Model | | Unstandardized Coefficients | | Standardized Coefficients | t | Sig. | Correlations | | |
| | B | Std. Error | Beta | | | Zero-order | Partial | Part |
1 | (Constant) | 3.618 | 1.242 | | 2.914 | .019 | | | |
| 수입 | .015 | .004 | .794 | 3.700 | .006 | .794 | .794 | .794 |
2 | (Constant) | 6.399 | 1.517 | | 4.220 | .004 | | | |
| 수입 | .012 | .004 | .616 | 3.325 | .013 | .794 | .783 | .565 |
| 가족숫자 | -.545 | .226 | -.446 | -2.406 | .047 | -.692 | -.673 | -.409 |
a. Dependent Variable: 통장갯수 |
http://imaging.mrc-cbu.cam.ac.uk/statswiki/FAQ/hier
https://ww2.coastal.edu/kingw/statistics/R-tutorials/multregr.html
r
datavar <- read.csv("http://commres.net/wiki/_media/regression01-bankaccount.csv")
datavar
m1 <- lm(bankaccount~income+famnum, data=datavar)
summary(m1)
library(ppcor)
spcor(datavar)
pcor(datavar)
> datavar <- read.csv("http://commres.net/wiki/_media/regression01-bankaccount.csv")
> datavar
bankaccount income famnum
1 6 220 5
2 5 190 6
3 7 260 3
4 7 200 4
5 8 330 2
6 10 490 4
7 8 210 3
8 11 380 2
9 9 320 1
10 9 270 3
> m1 <- lm(bankaccount~income+famnum, data=datavar)
> summary(m1)
Call:
lm(formula = bankaccount ~ income + famnum, data = datavar)
Residuals:
Min 1Q Median 3Q Max
-1.2173 -0.5779 -0.1515 0.6642 1.1906
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 6.399103 1.516539 4.220 0.00394 **
income 0.011841 0.003561 3.325 0.01268 *
famnum -0.544727 0.226364 -2.406 0.04702 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.9301 on 7 degrees of freedom
Multiple R-squared: 0.7981, Adjusted R-squared: 0.7404
F-statistic: 13.84 on 2 and 7 DF, p-value: 0.003696
> library(ppcor)
> spcor(datavar)
$estimate
bankaccount income famnum
bankaccount 1.0000000 0.5646726 -0.4086619
income 0.7171965 1.0000000 0.2078919
famnum -0.6166940 0.2470028 1.0000000
$p.value
bankaccount income famnum
bankaccount 0.00000000 0.113182 0.2748117
income 0.02964029 0.000000 0.5914441
famnum 0.07691195 0.521696 0.0000000
$statistic
bankaccount income famnum
bankaccount 0.000000 1.8101977 -1.1846548
income 2.722920 0.0000000 0.5623159
famnum -2.072679 0.6744045 0.0000000
$n
[1] 10
$gp
[1] 1
$method
[1] "pearson"
> pcor(datavar)
$estimate
bankaccount income famnum
bankaccount 1.0000000 0.7825112 -0.6728560
income 0.7825112 1.0000000 0.3422911
famnum -0.6728560 0.3422911 1.0000000
$p.value
bankaccount income famnum
bankaccount 0.00000000 0.01267595 0.04702022
income 0.01267595 0.00000000 0.36723388
famnum 0.04702022 0.36723388 0.00000000
$statistic
bankaccount income famnum
bankaccount 0.000000 3.3251023 -2.4064253
income 3.325102 0.0000000 0.9638389
famnum -2.406425 0.9638389 0.0000000
$n
[1] 10
$gp
[1] 1
$method
[1] "pearson"
## zero-order correlation
> cor(datavar)
bankaccount income famnum
bankaccount 1.0000000 0.7944312 -0.6922935
income 0.7944312 1.0000000 -0.3999614
famnum -0.6922935 -0.3999614 1.0000000
>
semipartial (part): spcor()
| bankaccount | income | famnum |
bankaccount | 1.0000000 | 0.5646726 | -0.4086619 |
income | 0.7171965 | 1.0000000 | 0.2078919 |
famnum | -0.6166940 | 0.2470028 | 1.0000000 |
| bankaccount | income | famnum |
bankaccount | 1.0000000 | 0.7825112 | -0.6728560 |
income | 0.7825112 | 1.0000000 | 0.3422911 |
famnum | -0.6728560 | 0.3422911 | 1.0000000 |
| bankaccount | income | famnum |
bankaccount | 1.0000000 | 0.7944312 | -0.6922935 |
income | 0.7944312 | 1.0000000 | -0.3999614 |
famnum | -0.6922935 | -0.3999614 | 1.0000000 |
pcor.test(datavar$bankaccount, datavar$income, datavar$famnum)
pcor.test(datavar$bankaccount, datavar$famnum, datavar$income)
spcor.test(datavar$bankaccount, datavar$income, datavar$famnum)
spcor.test(datavar$bankaccount, datavar$famnum, datavar$income)
. . .
> pcor.test(datavar$bankaccount, datavar$income, datavar$famnum)
estimate p.value statistic n gp Method
1 0.7825112 0.01267595 3.325102 10 1 pearson
> pcor.test(datavar$bankaccount, datavar$famnum, datavar$income)
estimate p.value statistic n gp Method
1 -0.672856 0.04702022 -2.406425 10 1 pearson
>
> spcor.test(datavar$bankaccount, datavar$income, datavar$famnum)
estimate p.value statistic n gp Method
1 0.5646726 0.113182 1.810198 10 1 pearson
> spcor.test(datavar$bankaccount, datavar$famnum, datavar$income)
estimate p.value statistic n gp Method
1 -0.4086619 0.2748117 -1.184655 10 1 pearson
>
>