Principal Component Analysis (PCA).
It is a special (simplified) case of EOF analysis offered as a separate
procedure for clarity/familiarity. It calls s_lin_eof with equal weights.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | x(nd,nv) |
input data |
||
| integer(kind=i4), | intent(in) | :: | nd |
number of rows |
||
| integer(kind=i4), | intent(in) | :: | nv |
number of columns |
||
| real(kind=wp), | intent(out) | :: | pc(nd,nv) |
principal components |
||
| real(kind=wp), | intent(out) | :: | ev(nv,nv) |
eigenvectors (unweighted) |
||
| real(kind=wp), | intent(out) | :: | ew(nv) |
eigenvalues |
||
| real(kind=wp), | intent(out), | optional | :: | r2(nv) |
explained variance (fraction) |
subroutine s_lin_pca(x, nd, nv, pc, ev, ew, r2) ! ==== Description !! Principal Component Analysis (PCA). !! It is a special (simplified) case of EOF analysis offered as a separate !! procedure for clarity/familiarity. It calls `s_lin_eof` with equal weights. ! ==== Declarations integer(i4), intent(in) :: nd !! number of rows integer(i4), intent(in) :: nv !! number of columns real(wp) , intent(in) :: x(nd,nv) !! input data real(wp) , intent(out) :: pc(nd,nv) !! principal components real(wp) , intent(out) :: ev(nv,nv) !! eigenvectors (unweighted) real(wp) , intent(out) :: ew(nv) !! eigenvalues real(wp) , intent(out), optional :: r2(nv) !! explained variance (fraction) real(wp) :: wt(nv) !! simple column weights ! ==== Instructions ! ---- handle input ! check matrix dimensions if (nd .lt. 2 .or. nv .lt. 1) then ! write error message and stop if invalid call s_err_print(fsml_error(3)) error stop endif ! ---- conduct analysis ! set weights to 1 wt = 1.0_wp ! call EOF procedure with simple weights and specify use of covariance matrix (opt=0) if (present(r2)) then call s_lin_eof(x, nd, nv, pc=pc, eof=ev, ew=ew, opt=0, wt=wt, r2=r2) else call s_lin_eof(x, nd, nv, pc=pc, eof=ev, ew=ew, opt=0, wt=wt) endif end subroutine s_lin_pca