NAG Library Routine Document G02CFF.1

Similar documents
NAG Library Routine Document G02BGF.1

NAG Fortran Library Routine Document G01ADF.1

NAG Library Routine Document G01ABF.1

NAG Library Routine Document G02BUF.1

NAG Fortran Library Routine Document F11ZPF.1

NAG Fortran Library Routine Document F01CTF.1

NAG Fortran Library Routine Document F01CWF.1

NAG Library Routine Document G02BXF.1

NAG Library Routine Document F04MCF.1

NAG Fortran Library Routine Document G08AJF.1

NAG Fortran Library Routine Document F04JAF.1

NAG Fortran Library Routine Document G01AJF.1

NAG Library Routine Document F04JAF.1

NAG Fortran Library Routine Document G08AKF.1

NAG Fortran Library Routine Document F04JGF.1

NAG Fortran Library Routine Document G02HKF.1

NAG Library Routine Document H03ADF.1

NAG Library Routine Document G05PZF.1

NAG Library Routine Document G02DDF.1

NAG Fortran Library Routine Document G01ARF.1

NAG Fortran Library Routine Document G05LZF.1

NAG Library Routine Document E04GYF.1

NAG Library Routine Document G05PZF.1

NAG Fortran Library Routine Document E02BCF.1

NAG Fortran Library Routine Document G01NBF.1

NAG Library Routine Document G13DMF.1

NAG Fortran Library Routine Document G05RAF.1

NAG Fortran Library Routine Document F04CAF.1

NAG Library Routine Document G01AJF.1

NAG Fortran Library Routine Document F04BGF.1

NAG Library Routine Document F04BEF.1

NAG Fortran Library Routine Document C05PBF.1

NAG Library Routine Document G05REF.1

NAG Library Routine Document G05RGF.1

NAG Fortran Library Routine Document F04DHF.1

NAG Library Routine Document G02GPF.1

NAG Library Routine Document G13DPF.1

NAG Fortran Library Routine Document F04BJF.1

NAG Fortran Library Routine Document F04CJF.1

F01BSF NAG Fortran Library Routine Document

NAG Fortran Library Routine Document E01AEF.1

NAG Library Routine Document C05RBF.1

NAG Fortran Library Routine Document D01AJF.1

NAG Fortran Library Routine Document X04CBF.1

NAG Library Routine Document G05PGF.1

NAG Library Routine Document E02DFF.1

E02ZAF NAG Fortran Library Routine Document

NAG Library Routine Document C05PBF/C05PBA

NAG Fortran Library Routine Document F08FQF (CHEEVD=ZHEEVD).1

NAG Library Routine Document G02DAF.1

NAG Library Routine Document E02BCF.1

NAG Library Routine Document C05QBF.1

NAG Library Routine Document D02UCF.1

NAG Fortran Library Routine Document F07AAF (DGESV).1

NAG Fortran Library Routine Document D02MVF.1

NAG Library Routine Document F08LEF (DGBBRD)

NAG Fortran Library Routine Document F11DSF.1

F02WUF NAG Fortran Library Routine Document

NAG Library Routine Document D02MWF.1

NAG Library Routine Document D04AAF.1

NAG Library Routine Document F07MAF (DSYSV).1

NAG Library Routine Document F07KDF (DPSTRF)

NAG Library Routine Document E02DAF.1

NAG Library Routine Document D02UAF.1

NAG Library Routine Document G12ABF.1

NAG Library Routine Document G13CDF.1

D01ARF NAG Fortran Library Routine Document

NAG Fortran Library Routine Document F08BHF (DTZRZF).1

NAG Fortran Library Routine Document D02PZF.1

NAG Fortran Library Routine Document F08KAF (DGELSS).1

D01FCF NAG Fortran Library Routine Document

NAG Library Routine Document F08ASF (ZGEQRF).1

NAG Library Routine Document D01BAF.1

NAG Library Routine Document D02HBF.1

NAG Library Routine Document E04GBF.1

NAG Fortran Library Routine Document D02KAF.1

NAG Library Routine Document F08ZNF (ZGGLSE)

C05 Roots of One or More Transcendental Equations. C05PCF NAG Fortran Library Routine Document

NAG Library Routine Document F08FAF (DSYEV)

NAG Library Routine Document F08NGF (DORMHR).1

F04EBFP.1. NAG Parallel Library Routine Document

NAG Library Routine Document F08BVF (ZTZRZF)

E01DAF NAG Fortran Library Routine Document

NAG Library Routine Document D02ZAF.1

E04JAF NAG Fortran Library Routine Document

E04FDFP.1. NAG Parallel Library Routine Document

G07EAF NAG Fortran Library Routine Document

NAG Library Routine Document F08FDF (DSYEVR)

E04JYF NAG Fortran Library Routine Document

NAG Fortran Library Routine Document E04UQF=E04UQA.1

F01XPFP.1. NAG Parallel Library Routine Document

NAG Library Routine Document E04WEF.1

E04DGF NAG Fortran Library Routine Document

D02KAF NAG Fortran Library Routine Document

NAG Toolbox for MATLAB. g02ef.1

F11DCFP.1. NAG Parallel Library Routine Document

NAG Library Routine Document H02CFF.1

D01GCF NAG Fortran Library Routine Document

NAG Library Routine Document E04UDF/E04UDA

G13CDF NAG Fortran Library Routine Document

Transcription:

G2 orrelation and Regression Analysis NAG Library Routine Document Note before using this routine, please read the Users Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details Purpose reorders the elements in two vectors (typically vectors of means and standard deviations), and the rows and columns in two matrices (typically either matrices of sums of squares and cross-products of deviations from means and Pearson product-moment correlation coefficients, or matrices of sums of squares and cross-products about zero and correlation-like coefficients) 2 Specification SUROUTINE (N, KORDER, XAR, STD, SSP, LDSSP, R, LDR, KWORK, IFAIL) INTEGER N, KORDER(N), LDSSP, LDR, KWORK(N), IFAIL double precision XAR(N), STD(N), SSP(LDSSP,N), R(LDR,N) 3 Description Input to the routine consists of (a) A list of the order in which the n variables are to be arranged on exit i ;i 2 ;i 3 ; ;i n (b) A vector of means ðx ; x 2 ; x 3 ; ; x n Þ (c) A vector of standard deviations ðs ;s 2 ;s 3 ; ;s n Þ (d) A matrix of sums of squares and cross-products of deviations from means S S 2 S 3 S n S 2 S 22 S 3 @ A S n S n2 S nn (e) A matrix of correlation coefficients R R 2 R 3 R n R 2 R 22 R 3 @ A R n R n2 R nn On exit from the routine, these same vectors and matrices are reordered, in the manner specified, and contain the following information

NAG Library Manual (i) The vector of means x i ; x i2 ; x i3 ; ; x in (ii) The vector of standard deviations s i ;s i2 ;s i3 ; s in (iii) The matrix of sums of squares and cross-products of deviations from means S i i S i i 2 S i i 3 S i i n S i2 i S i2 i 2 S i3 i @ A S in i S in i 2 S in i n (iv) The matrix of correlation coefficients R i i R i i 2 R i i 3 R i i n R i2 i R i2 i 2 R i3 i @ A R in i R in i 2 R in i n Note for sums of squares of cross-products of deviations about zero and correlation-like coefficients S ij and R ij should be replaced by ~ S ij and ~R ij in the description of the input and output above 4 References None 5 Parameters N INTEGER Input On entry n, the number of variables in the input data onstraint N 2 2 KORDERðNÞ INTEGER array Input On entry KORDERðiÞ must be set to the number of the original variable which is to be the ith variable in the re-arranged data, for i ¼ ; 2; ;n onstraint KORDERðiÞ N, for i ¼ ; 2; ;n 3 XARðNÞ double precision array Input/Output On entry XARðiÞ must be set to the mean of variable i, for i ¼ ; 2; ;n On exit XARðiÞ contains the mean of variable k where k ¼ KORDERðiÞ, for i ¼ ; 2; ;n 4 STDðNÞ double precision array Input/Output On entry STDðiÞ must be set to the standard deviation of variable i, for i ¼ ; 2; ;n On exit STDðiÞ contains the standard deviation of variable k where k ¼ KORDERðiÞ, for i ¼ ; 2; ;n 2

G2 orrelation and Regression Analysis 5 SSPðLDSSP,NÞ double precision array Input/Output On entry SSPði; jþ must be set to the sum of cross-products of deviations from means S ij (or about zero S ~ ij ) for variables i and j, for i; j ¼ ; 2; ;n On exit SSPði; jþ contains the sum of cross-products of deviations from means S kl (or about zero ~S kl ) for variables k and l, where k ¼ KORDERðiÞ, and l ¼ KORDERðjÞ, i; j ¼ ; 2; ;n 6 LDSSP INTEGER Input On entry the first dimension of the array SSP as declared in the (sub)program from which is called onstraint LDSSP N 7 RðLDR,NÞ double precision array Input/Output On entry Rði; jþ must be set to the Pearson product-moment correlation coefficient R ij (or the correlation-like coefficient ~R ij ) for variables i and j, for i; j ¼ ; 2; ;n On exit Rði; jþ contains the Pearson product-moment correlation coefficient R kl (or the correlationlike coefficient ~R kl ) for variables k and l, where k ¼ KORDERðiÞ and l ¼ KORDERðjÞ, for i; j ¼ ; 2; ;n 8 LDR INTEGER Input On entry the first dimension of the array R as declared in the (sub)program from which is called onstraint LDR N 9 KWORKðNÞ INTEGER array Workspace IFAIL INTEGER Input/Output On entry IFAIL must be set to, or If you are unfamiliar with this parameter you should refer to Section 33 in the Essential Introduction for details On exit IFAIL ¼ unless the routine detects an error (see Section 6) For environments where it might be inappropriate to halt program execution when an error is detected, the value or is recommended If the output of error messages is undesirable, then the value is recommended Otherwise, if you are not familiar with this parameter, the recommended value is When the value or is used it is essential to test the value of IFAIL on exit 6 Error Indicators and Warnings If on entry IFAIL ¼ or, explanatory error messages are output on the current error message unit (as defined by X4AAF) Errors or warnings detected by the routine IFAIL ¼ On entry, N < 2 IFAIL ¼ 2 On entry, LDSSP < N, or LDR < N 3

NAG Library Manual IFAIL ¼ 3 On entry, KORDERðiÞ <, or KORDERðiÞ > N for some i ¼ ; 2; ;n IFAIL ¼ 4 On entry, there is not a one-to-one correspondence between the old variables and the new variables; at least one of the original variables is not included in the new set, and consequently at least one other variable has been included more than once 7 Accuracy Not applicable 8 Further omments The time taken by depends on n and the amount of re-arrangement involved The routine is intended primarily for use when a set of variables is to be reordered for use in a regression, and is described accordingly There is however no reason why the routine should not also be used to reorder vectors and matrices which contain any other non-statistical information; the matrices need not be symmetric The routine may be used either with sums of squares and cross-products of deviations from means and Pearson product-moment correlation coefficients in connection with a regression involving a constant, or with sums of squares and cross-products about zero and correlation-like coefficients in connection with a regression with no constant 9 Example This example reads in the means, standard deviations, sums of squares and cross-products, and correlation coefficients for three variables The vectors and matrices are reordered so that they contain the means, standard deviations, sums of squares and cross-products, and correlation coefficients for the first, third and second variables (in that order) Finally the reordered vectors and matrices are printed 9 Program Text * Example Program Text * Mark 4 Revised NAG opyright 989 * Parameters INTEGER N, LDSSP, LDR PARAMETER (N=3,LDSSP=N,LDR=N) INTEGER NIN, NOUT PARAMETER (NIN=5,NOUT=6) * Local Scalars INTEGER I, IFAIL, J * Local Arrays DOULE PREISION R(LDR,N), SSP(LDSSP,N), STD(N), XAR(N) INTEGER KORDER(N), KWORK(N) * External Subroutines EXTERNAL * Executable Statements Example Program Results * Skip heading in data file READ (NIN,*) READ (NIN,*) (XAR(I),I=,N), (STD(I),I=,N), + ((SSP(I,J),J=,N),I=,N), ((R(I,J),J=,N),I=,N) WRITE (NOUT,99999) Original vector XAR, (XAR(I),I=,N) WRITE (NOUT,99999) Original vector STD, (STD(I),I=,N) Original matrix SSP WRITE (NOUT,99998) ((SSP(I,J),J=,N),I=,N) 4

G2 orrelation and Regression Analysis Original matrix R WRITE (NOUT,99998) ((R(I,J),J=,N),I=,N) KORDER() = KORDER(2) = 3 KORDER(3) = 2 IFAIL = * ALL (N,KORDER,XAR,STD,SSP,LDSSP,R,LDR,KWORK,IFAIL) * IF (IFAILNE) THEN WRITE (NOUT,99997) ** returned with IFAIL =, IFAIL ELSE WRITE (NOUT,99996) New vector XAR, (XAR(I),I=,N) WRITE (NOUT,99996) New vector STD, (STD(I),I=,N) New matrix SSP WRITE (NOUT,99995) ((SSP(I,J),J=,N),I=,N) New matrix R WRITE (NOUT,99995) ((R(I,J),J=,N),I=,N) END IF * 99999 FORMAT (X,A,3F4) 99998 FORMAT (X,3F4) 99997 FORMAT (X,A,I5) 99996 FORMAT (X,A,3F4) 99995 FORMAT (X,3F4) END 92 Program Data Example Program Data 54 58 28 498 5695 924 992-576 64-576 28-292 64-292 48-574 67-574 -7486 67-7486 93 Program Results Example Program Results Original vector XAR 54 58 28 Original vector STD 498 5695 924 Original matrix SSP 992-576 64-576 28-292 64-292 48 Original matrix R -574 67-574 -7486 67-7486 New vector XAR 54 28 58 New vector STD 498 924 5695 New matrix SSP 992 64-576 64 48-292 5

NAG Library Manual -576-292 28 New matrix R 67-574 67-7486 -574-7486 6 (last)