factor_analysis
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
factor_analysis [2018/12/05 12:14] – [Factor solution among many . . .] hkimscil | factor_analysis [2019/11/01 02:53] – [E.g. 2] hkimscil | ||
---|---|---|---|
Line 74: | Line 74: | ||
\end{equation} | \end{equation} | ||
- | 위 식 [1]에서 e는 error term을 말하고, F1, F2 는 각각 잠재적인 요인이다. finance, marketing, policy 점수는 F1과 F2의 기여로 만들어지는 점수이다. F1과 F2가 observation에 기초한 변인이 아니므로 데이터를 이용한 regression을 구하는 방법은 적당치 | + | 위 식 [1]에서 e는 error term을 말하고, F1, F2 는 각각 잠재적인 요인이다. finance, marketing, policy 점수는 F1과 F2의 기여로 만들어지는 점수이다. F1과 F2가 observation에 기초한 변인이 아니므로 데이터를 이용한 regression을 구하는 방법은 적당치 |
한편, $\beta_{ij}$ 는 표준화된 correlation coefficient 값을 말한다 (regression에서 beta값) -- factor analysis에서는 흔히 factor loading이라고 부른다. beta를 해석하는 방법과 마찬가지로 factor loading 값은 F1이나 F2의 인자가 finance (혹은 다른 변인 점수) 점수에 얼마나 기여하는지를 나타내 주는 지표라고 하겠다. | 한편, $\beta_{ij}$ 는 표준화된 correlation coefficient 값을 말한다 (regression에서 beta값) -- factor analysis에서는 흔히 factor loading이라고 부른다. beta를 해석하는 방법과 마찬가지로 factor loading 값은 F1이나 F2의 인자가 finance (혹은 다른 변인 점수) 점수에 얼마나 기여하는지를 나타내 주는 지표라고 하겠다. | ||
Line 91: | Line 91: | ||
위의 요인이 포함된 regression공식이 갖는 가정은 다음과 같다. | 위의 요인이 포함된 regression공식이 갖는 가정은 다음과 같다. | ||
- $E(e_{i}) = 0, \quad Var(e_{i}) = \sigma^2_{i}$ | - $E(e_{i}) = 0, \quad Var(e_{i}) = \sigma^2_{i}$ | ||
+ | * error의 분포에 관한 내용이다. | ||
* expected value = mean of error terms = 0, with standard deviation = $\sigma_{i}$ | * expected value = mean of error terms = 0, with standard deviation = $\sigma_{i}$ | ||
* 에러는 평균 0을 중심으로 무작위로 펼쳐져 있는 상태가 가정되므로 위와 같은 성격을 갖는다. | * 에러는 평균 0을 중심으로 무작위로 펼쳐져 있는 상태가 가정되므로 위와 같은 성격을 갖는다. | ||
- $E(F_{j}) = 0, \quad Var(F_{j}) = 1 $ | - $E(F_{j}) = 0, \quad Var(F_{j}) = 1 $ | ||
+ | * F는 표준화된 coefficient로 | ||
* Factors are standardized with mean =0, standard deviation = 1. Hence, Var(F) = 1. | * Factors are standardized with mean =0, standard deviation = 1. Hence, Var(F) = 1. | ||
* factors의 계수를 내기 전의 data는 표준점수 처리가 된 것을 가정한다. 따라서, F의 mean과 standard deviation값은 각각 0과 1이어야 하고, 따라서 F의 variance값 또한 1이 된다. | * factors의 계수를 내기 전의 data는 표준점수 처리가 된 것을 가정한다. 따라서, F의 mean과 standard deviation값은 각각 0과 1이어야 하고, 따라서 F의 variance값 또한 1이 된다. | ||
Line 280: | Line 282: | ||
| Variable, \\ Y< | | Variable, \\ Y< | ||
| (1) | (2) | $F_{1}, b_{i1}$ \\ (3) | $F_{2}, b_{i2}$ \\ (4) | (5) | (6) = 100 x (5)/ | | (1) | (2) | $F_{1}, b_{i1}$ \\ (3) | $F_{2}, b_{i2}$ \\ (4) | (5) | (6) = 100 x (5)/ | ||
- | | Finance, $Y_{1}$ | + | | Finance, $Y_{1}$ |
- | | Marketing, $Y_{2}$ | + | | Marketing, $Y_{2}$ |
- | | policy, $Y_{3}$ | + | | policy, $Y_{3}$ |
| Overall \\ SS loadings | | Overall \\ SS loadings | ||
| | | 55.1% \\ (10) / (9) = | 44.7% \\ (11) / (9) = | | | | | | | | 55.1% \\ (10) / (9) = | 44.7% \\ (11) / (9) = | | | | | ||
+ | 각주 1) -> finance = 수학능력 = F1 | ||
+ | 각주 2), 3) -> marketing, policy = 언어능력 = F2 | ||
+ | 각주 4)는 아래와 같이 구함 | ||
+ | < | ||
+ | > l.f <- 3.136773 | ||
+ | > l.m <- -0.132190 | ||
+ | > l.p <- 0.127697 | ||
+ | > loadings.f1 <- c(l.f, | ||
+ | > sum(loadings.f1^2) # value of (10) in the above table | ||
+ | [1] 9.873126 | ||
+ | > </ | ||
+ | |||
+ | |||
+ | |||
+ | < | ||
+ | > fd | ||
+ | finance marketing policy | ||
+ | 1 | ||
+ | 2 | ||
+ | 3 10 | ||
+ | 4 | ||
+ | 5 10 | ||
+ | |||
+ | 아래는 population variance, sd를 구하기 위한 function | ||
+ | < | ||
+ | + | ||
+ | + } | ||
+ | > psd <- function(x) { | ||
+ | + sqrt (sum((x - mean(x))**2) / length(x)) | ||
+ | + }</ | ||
+ | |||
+ | < | ||
+ | > tapply(fds$values, | ||
+ | finance marketing | ||
+ | 6.6 | ||
+ | > tapply(fds$values, | ||
+ | finance marketing | ||
+ | | ||
+ | > options(digits=5) | ||
+ | > tapply(fds$values, | ||
+ | finance marketing | ||
+ | | ||
+ | > | ||
+ | </ | ||
| Standardized \\ Variable, \\ Y< | | Standardized \\ Variable, \\ Y< | ||
Line 387: | Line 433: | ||
> data <- read.csv(" | > data <- read.csv(" | ||
> data <- read.csv(" | > data <- read.csv(" | ||
+ | > data <- read.csv(" | ||
> #display the data (warning: large output - only the first 10 rows are shown here) | > #display the data (warning: large output - only the first 10 rows are shown here) | ||
Line 1102: | Line 1149: | ||
====== e.g., 5 ====== | ====== e.g., 5 ====== | ||
{{: | {{: | ||
+ | ====== e.g. secu com finance 2007 example | ||
+ | {{: | ||
+ | |||
+ | < | ||
+ | Sys.setlocale(" | ||
+ | secu_com_finance_2007 <- read.csv(" | ||
+ | secu_com_finance_2007 | ||
+ | |||
+ | # V1 : 총자본순이익율 | ||
+ | # V2 : 자기자본순이익율 | ||
+ | # V3 : 자기자본비율 | ||
+ | # V4 : 부채비율 | ||
+ | # V5 : 자기자본회전율 | ||
+ | |||
+ | # 표준화 변환 (standardization) | ||
+ | secu_com_finance_2007 <- transform(secu_com_finance_2007, | ||
+ | V1_s = scale(V1), | ||
+ | V2_s = scale(V2), | ||
+ | V3_s = scale(V3), | ||
+ | V4_s = scale(V4), | ||
+ | V5_s = scale(V5)) | ||
+ | |||
+ | # 부채비율(V4_s)을 방향(max(V4_s)-V4_s) 변환 | ||
+ | secu_com_finance_2007 <- transform(secu_com_finance_2007, | ||
+ | |||
+ | # variable selection | ||
+ | secu_com_finance_2007_2 <- secu_com_finance_2007[, | ||
+ | |||
+ | # Correlation analysis | ||
+ | cor(secu_com_finance_2007_2[, | ||
+ | |||
+ | round(cor(secu_com_finance_2007_2[, | ||
+ | |||
+ | # Scatter plot matrix | ||
+ | plot(secu_com_finance_2007_2[, | ||
+ | |||
+ | # Scree Plot | ||
+ | plot(prcomp(secu_com_finance_2007_2[, | ||
+ | |||
+ | </ | ||
+ | |||
+ | < | ||
+ | # 요인분석(maximum likelihood factor analysis) | ||
+ | # rotation = " | ||
+ | secu_factanal <- factanal(secu_com_finance_2007_2[, | ||
+ | factors = 2, | ||
+ | rotation = " | ||
+ | scores=" | ||
+ | print(secu_factanal) | ||
+ | |||
+ | </ | ||
+ | |||
+ | < | ||
+ | print(secu_factanal$loadings, | ||
+ | |||
+ | # factor scores plotting | ||
+ | secu_factanal$scores | ||
+ | |||
+ | plot(secu_factanal$scores, | ||
+ | |||
+ | # 관측치별 이름 매핑(rownames mapping) | ||
+ | text(secu_factanal$scores[, | ||
+ | | ||
+ | cex = 0.7, pos = 3, col = " | ||
+ | |||
+ | # factor loadings plotting | ||
+ | points(secu_factanal$loadings, | ||
+ | |||
+ | |||
+ | text(secu_factanal$loadings[, | ||
+ | | ||
+ | cex = 0.8, pos = 3, col = " | ||
+ | |||
+ | # plotting lines between (0,0) and (factor loadings by Var.) | ||
+ | segments(0, | ||
+ | segments(0, | ||
+ | segments(0, | ||
+ | segments(0, | ||
+ | segments(0, | ||
+ | |||
+ | |||
+ | |||
+ | </ | ||
====== etc. ====== | ====== etc. ====== | ||
< | < | ||
{{: | {{: | ||
{{: | {{: | ||
- | {{: | + | |
====== Reference ====== | ====== Reference ====== | ||
{{: | {{: | ||
factor_analysis.txt · Last modified: 2023/11/06 02:53 by hkimscil