matlab rotatefactors,Rotate factor loadings

rotatefactors

Rotate factor loadings

Syntax

B = rotatefactors(A)

B = rotatefactors(A,'Method','orthomax','Coeff',gamma)

B = rotatefactors(A,'Method','procrustes','Target',target)

B = rotatefactors(A,'Method','pattern','Target',target)

B = rotatefactors(A,'Method','promax')

[B,T] = rotatefactors(A,...)

Description

B = rotatefactors(A) rotates the d-by-m loadings

matrix A to maximize the varimax criterion, and

returns the result in B. Rows of A and B correspond

to variables and columns correspond to factors, for example, the (i, j)th

element of A is the coefficient for the i th

variable on the j th factor. The matrix A usually

contains principal component coefficients created with pca or pcacov,

or factor loadings estimated with factoran.

B = rotatefactors(A,'Method','orthomax','Coeff',gamma) rotates A to

maximize the orthomax criterion with the coefficient gamma,

i.e., B is the orthogonal rotation of A that

maximizes

sum(D*sum(B.^4,1) - GAMMA*sum(B.^2,1).^2)

The default value of 1 for gamma corresponds

to varimax rotation. Other possibilities include gamma =

0, m/2, and d(m-

1)/(d+ m - 2), corresponding

to quartimax, equamax, and parsimax. You can also supply 'varimax', 'quartimax', 'equamax',

or 'parsimax' for the 'method' parameter

and omit the 'Coeff' parameter.

If 'Method' is 'orthomax', 'varimax', 'quartimax', 'equamax',

or 'parsimax', then additional parameters are

'Normalize' — Flag indicating

whether the loadings matrix should be row-normalized for

rotation. If 'on' (the default), rows of A are

normalized prior to rotation to have unit Euclidean norm, and unnormalized

after rotation. If 'off', the raw loadings are

rotated and returned.

'Reltol' — Relative convergence

tolerance in the iterative algorithm used to find T.

The default is sqrt(eps).

'Maxit' — Iteration limit

in the iterative algorithm used to find T. The

default is 250.

B = rotatefactors(A,'Method','procrustes','Target',target) performs

an oblique procrustes rotation of A to the d-by-m target

loadings matrix target.

B = rotatefactors(A,'Method','pattern','Target',target) performs

an oblique rotation of the loadings matrix A to

the d-by-m target pattern

matrix target, and returns the result in B. target defines

the "restricted" elements of B, i.e., elements

of B corresponding to zero elements of target are

constrained to have small magnitude, while elements of B corresponding

to nonzero elements of target are allowed to take

on any magnitude.

If 'Method' is 'procrustes' or 'pattern',

an additional parameter is 'Type', the type of

rotation. If 'Type' is 'orthogonal',

the rotation is orthogonal, and the factors remain uncorrelated.

If 'Type' is 'oblique' (the

default), the rotation is oblique, and the rotated factors might be

correlated.

When 'Method' is 'pattern',

there are restrictions on target. If A has m columns,

then for orthogonal rotation, the jth column of target must

contain at least m - j zeros.

For oblique rotation, each column of target must

contain at least m - 1 zeros.

B = rotatefactors(A,'Method','promax') rotates

A to maximize the promax criterion, equivalent to an oblique Procrustes

rotation with a target created by an orthomax rotation. Use the four

orthomax parameters to control the orthomax rotation used internally

by promax.

An additional parameter for 'promax' is 'Power',

the exponent for creating promax target matrix. 'Power' must

be 1 or greater. The default is 4.

[B,T] = rotatefactors(A,...) returns the

rotation matrix T used to create B,

that is, B = A*T. You can find the correlation

matrix of the rotated factors by using inv(T'*T).

For orthogonal rotation, this is the identity matrix, while for oblique

rotation, it has unit diagonal elements but nonzero off-diagonal elements.

Examples

rng('default') % for reproducibility

X = randn(100,10);

% Default (normalized varimax) rotation:

% first three principal components.

LPC = pca(X);

[L1,T] = rotatefactors(LPC(:,1:3));

% Equamax rotation:

% first three principal components.

[L2,T] = rotatefactors(LPC(:,1:3),...

'method','equamax');

% Promax rotation:

% first three factors.

LFA = factoran(X,3,'Rotate','none');

[L3,T] = rotatefactors(LFA(:,1:3),...

'method','promax',...

'power',2);

% Pattern rotation:

% first three factors.

Tgt = [1 1 1 1 1 0 1 0 1 1; ...

0 0 0 1 1 1 0 0 0 0; ...

1 0 0 1 0 1 1 1 1 0]';

[L4,T] = rotatefactors(LFA(:,1:3),...

'method','pattern',...

'target',Tgt);

inv(T'*T) % Correlation matrix of the rotated factors

ans =

1.0000 -0.9593 -0.7098

-0.9593 1.0000 0.5938

-0.7098 0.5938 1.0000

References

[1] Harman, H. H. Modern Factor

Analysis. 3rd ed. Chicago: University of Chicago Press,

1976.

[2] Lawley, D. N., and A. E. Maxwell. Factor

Analysis as a Statistical Method. 2nd ed. New York: American

Elsevier Publishing, 1971.

Introduced before R2006a

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这段代码是使用 MATLAB 进行主成分分析(PCA)并对结果进行旋转变换的过程,下面是对每一行代码的解释: ```matlab clc,clear % 清除命令行窗口和工作区中的变量 data=[123 54 66 ... 25 333 89]; % 载入原始数据 n=size(data,1); x=data x=zscore(x); % 数据标准化 r=cov(x) % 求标准化数据的协方差阵,即求相关系数矩阵 [vec,val,con]=pcacov(r) % 进行主成分分析的相关计算 num=input('请选择主因子的个数:'); % 交互式选择主因子的个数 f1=repmat(sign(sum(vec)),size(vec,1),1); vec=vec.*f1; % 特征向量正负号转换 f2=repmat(sqrt(val)',size(vec,1),1); a=vec.*f2 % 求初等载荷矩阵 am=a(:,1:num); % 提出 num 个主因子的载荷矩阵 [b,t]=rotatefactors(am,'method', 'varimax') % 旋转变换,b 为旋转后的载荷阵 bt=[b,a(:,num+1:end)]; % 旋转后全部因子的载荷矩阵 contr=sum(bt.^2) % 计算因子贡献 rate=contr(1:num)/sum(contr) % 计算因子贡献率 coef=inv(r)*b % 计算得分函数的系数 score=x*coef % 计算各个因子的得分 weight=rate/sum(rate) % 计算得分的权重 Tscore=score*weight' % 对各因子的得分进行加权求和,即求各地区综合得分 ``` 其中,`data` 是包含原始数据的向量,`cov()` 函数计算数据的协方差矩阵,`pcacov()` 函数进行主成分分析并返回一些相关结果。`rotatefactors()` 函数进行旋转变换,返回旋转后的载荷矩阵 `b`。后续代码计算因子贡献、因子贡献率、得分函数系数、各个因子的得分、得分的权重等,并最终求出各地区综合得分 `Tscore`。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值