您好,欢迎访问三七文档
因子分析,相较于主成分分析而言,通过对因子的旋转处理,使得我们可以更直观的认识到数据内部之间的关系,其目的即用有限个不可观测的因变量来解释原始变量间的相关关系。即用几个少数的综合因子来取代错综复杂关系的变量。因子分析函数:factanal(X,factors,scores=”none”,rotation=”varimax”)这个函数是基于极大似然方法求解X为数据,矩阵或者数据框factors为因子个数scores为因子得分的计算方法,”regression”,”Bartlett”rotation为因子旋转方法自编因子分析函数:factpc(X,m,scores=”none”,rotation=”varimax”)这个函数是基于主成分方法来求解的。极大似然法要求数据来自多元正态分布,这一点一般是很难满足的。而主成分法没有正态总体的要求。对于数据d9.1水泥行业运营因素做因子分析。输入:X=read.table(clipboard,header=T)cor(X)#计算相关系数矩阵#极大似然法进行因子分析FA0=factanal(X,3,rotation=none)FA0Call:factanal(x=X,factors=3,rotation=none)Uniquenesses:x1x2x3x4x5x60.0050.0050.0050.2710.0050.548Loadings:#因子载荷矩阵Factor1Factor2Factor3x10.950-0.307x20.948-0.310x3-0.340-0.7820.517x40.3630.561-0.531x50.4540.6930.556x60.3830.1630.527Factor1Factor2Factor3SSloadings2.4021.6231.140ProportionVar0.4000.2710.190#方差贡献率CumulativeVar0.4000.6710.861#累计方差贡献率Thedegreesoffreedomforthemodelis0andthefitwas1.1422#主成分法进行因子分析library(mvstats)FA1=factpc(X,3)$Vars#方差方差贡献率累计方差贡献率VarsVars.PropVars.CumFactor12.5700.428342.83Factor21.7130.285571.38Factor31.2490.208292.19$loadings#载荷矩阵Factor1Factor2Factor3x10.78290.5029-0.3624x20.78110.4964-0.3756x3-0.57860.76850.0802x40.5951-0.6990-0.2415x50.6317-0.14570.6557x60.50840.33670.6943$scores#因子得分Factor1Factor2Factor3冀东水泥1.108050.19287-0.40233大同水泥-1.071951.46385-0.37413四川双马-0.58577-0.498480.24193牡丹江-1.17442-0.777910.08986西水股份-0.05264-0.460732.31615狮头股份-1.050072.041510.25174太行股份0.208070.48809-0.23430海螺水泥2.207450.325241.16336尖峰集团-1.11541-1.532350.39013四川金顶0.09714-0.60602-1.45691祁连山0.660961.032930.04173华新水泥0.41359-1.083310.19805福建水泥0.86840-0.53255-1.82104天鹅股份-0.51340-0.05315-0.40422$Rank#得分排名FRi冀东水泥0.483593大同水泥-0.129108四川双马-0.3718411牡丹江-0.7661513西水股份0.355874狮头股份0.201275太行股份0.194906海螺水泥1.388821尖峰集团-0.9045714四川金顶-0.4715212祁连山0.636322华新水泥-0.098637福建水泥-0.172739天鹅股份-0.3462210$commonx1x2x3x4x5x60.99710.99760.93180.90110.85020.8539从上面结果来看,用极大似然法解释的方差为86%,基本可以全面反映六项财务指标的信息。用主成分法解释的方差为92%,效果要更好。因子个数也可用碎石图来看。因为三个因子的经济含义不明显,需要进行因子旋转。#极大似然法FA0=factanal(X,3,rotation=varimax)FA0Call:factanal(x=X,factors=3,rotation=varimax)Uniquenesses:x1x2x3x4x5x60.0050.0050.0050.2710.0050.548Loadings:Factor1Factor2Factor3x10.9830.155x20.9850.142x3-0.990-0.124x40.1270.844x50.2930.953x60.2100.631Factor1Factor2Factor3SSloadings1.9981.8001.367ProportionVar0.3330.3000.228CumulativeVar0.3330.6330.861Thedegreesoffreedomforthemodelis0andthefitwas1.1422#主成分方法library(mvstats)FA1=factpc(X,3,rotation=varimax)FactorAnalysisforPrincompinVarimax:FA1$Vars#方差方差贡献率累计方差贡献率VarsVars.PropVars.CumFactor12.01433.5633.56Factor21.93832.3065.87Factor31.58026.3392.19$loadings#旋转后载荷矩阵Factor1Factor2Factor3x10.9867090.072160.135305x20.9881400.079130.122314x3-0.009491-0.95685-0.127000x40.1352860.939540.004538x50.0441030.329420.860082x60.208451-0.141200.889083$scores#旋转后因子得分Factor1Factor2Factor3冀东水泥1.05710.5084650.22544大同水泥0.2509-1.704706-0.68039四川双马-0.79220.052388-0.14079牡丹江-1.2794-0.001121-0.59625西水股份-1.3825-0.0961181.91289狮头股份0.2910-2.290232-0.06280太行股份0.5235-0.246292-0.04099海螺水泥1.14760.6816312.13317尖峰集团-1.79820.594084-0.39758四川金顶0.41750.832941-1.27718祁连山1.0061-0.5077640.48519华新水泥-0.40921.0747360.24757福建水泥1.15921.253210-1.19980天鹅股份-0.1915-0.151222-0.60849$Rank#得分排名FRi冀东水泥0.6273812大同水泥-0.70025413四川双马-0.31024710牡丹江-0.63643912西水股份0.0092798狮头股份-0.71447614太行股份0.0925896海螺水泥1.2657731尖峰集团-0.56000011四川金顶0.0791247祁连山0.3269244华新水泥0.2982875福建水泥0.5185183天鹅股份-0.2964589$commonx1x2x3x4x5x60.99710.99760.93180.90110.85020.8539#极大似然法的函数没有给出排名情况,用自编函数library(mvstats)factanal.rank(FA1,plot=T)信息重叠图输入:biplot(FA0$scores,FA1$loading)#极大似然法的信息重叠图得到:d7.2:31个省、市、自治区的消费情况。用d7.2数据应用因子分析模型。X-read.table(clipboard,header=T)library(mvstats)FA0=factpc(X,3)#主成分法因子分析未旋转FA0$Vars#方差贡献率VarsVars.PropVars.CumFactor15.19250.6490764.91Factor21.26060.1575780.66Factor30.64710.0808888.75FA0$loadings#载荷矩阵Factor1Factor2Factor3X10.9114-0.071200.2423X20.32070.844000.2879X30.8274-0.01090-0.3958X40.78030.29371-0.4307X50.9138-0.152110.3033X60.93370.03035-0.1695X70.6569-0.646710.1130X80.90960.120460.1729由于公共因子在原始变量上的载荷值不太好解释,故对其进行因子旋转,选用方差最大化正交旋转。FA1=factpc(X,3,rotation=varimax)#主成分法因子分析旋转FA1$Vars#旋转后方差贡献率VarsVars.PropVars.CumFactor13.22940.3740.37Factor22.59632.4572.82Factor31.27515.9488.75FA1$loadings#旋转后载荷矩阵Factor1Factor2Factor3X10.837280.40150.17946X20.083340.16250.92987X30.396430.8267-0.02714X40.228380.88130.22782X50.903240.34250.13011X60.586080.73790.11553X70.791270.2182-0.43453X80.725640.48870.32604由旋转后的因子载荷矩阵可以看到:公共因子F1在X1(人均食品支出)、X5(人均交通和通讯支出)、x7(人均居住支出)、x8(人均杂项商品及服务支出)上的载荷值都很大,可视为反映日常必须消费的公共因子。公共因子F2在X3(人均家庭设备用品及服务支出)、x4(人均医疗保健支出)、x6(人均娱乐教育文化支出)上的载荷值很大,可视为反映相对高档消费的公共因子。公共因子F3仅在x2(人均衣着支出)上有很大的载荷,可视为衣着因子。这样就可以对各省、市、自治区的消费情况做评价。FA1$scores#因子得分Factor1Factor2Factor3北京0.602092.937981.639329天津0.533681.39166-0.946970河北-1.005530.42878-0.215804山西-0.983150.023630.005883内蒙古-0.40922-0.755550.551076辽宁-0.67890-0.173960.484714吉林-0.53301-0.519620.137665黑龙江-0.85858-0.227390.001374上海2.234811.270470.489859江苏-0.115320.26186-0.074807浙江0.622232.179140.168660安徽-0.26717-0.86766-0.297037福建0.94223-0.67815-0.337264江西-0.1
本文标题:8因子分析
链接地址:https://www.777doc.com/doc-5399642 .html