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/22 01:55] – hkimscil | factor_analysis [2019/09/14 18:56] – [e.g. secu com finance 2007 example] hkimscil | ||
---|---|---|---|
Line 1148: | Line 1148: | ||
====== 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