说明案例origin7 0软件删g03acc_第1页
说明案例origin7 0软件删g03acc_第2页
说明案例origin7 0软件删g03acc_第3页
说明案例origin7 0软件删g03acc_第4页
说明案例origin7 0软件删g03acc_第5页
已阅读5页,还剩2页未读 继续免费阅读

付费下载

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

g03–MultivariateMethods

g03acc

NAGCLibraryManual

nagmvcanonvar

[NP3275/5/pdf]

3.g03acc.

PAGE

1

3.g03acc.

PAGE

2

[NP3275/5/pdf]

nagmvcanonvar(g03acc)

Purpose

nagmvcanonvar(g03acc)performsacanonicalvariate(canonicaldescrimination)ysis.

Specification

#include<nag.h>#include<nagg03.h>

voidnag_mv_canon_var(Nag_Weightstypeweight,Integern,Integerm,doublex[],Integertdx,Integerisx[],Integernx,Integering[],Integerng,doublewt[],Integernig[],doublecvm[],Integertdcvm,

doublee[],Integertde,Integer*ncv,doublecvx[],Integertdcvx,doubletol,Integer*irankx,NagError*fail)

Description

P

Letasampleofnobservationsonnxvariablesinadatamatrixcomefromnggroupswithn1,n2,...,nngobservationsineachgroup,ni=n.Canonicalvariateysisfindsthelinearcombinationofthenxvariablesthat izestheratioofbetween-grouptowithin-groupvariation.Thevariablesformed,thecanonicalvariatescanthenbeusedtodiscriminatebetween

groups.

Thecanonicalvariatescanbecalculatedfromtheeigenvectorsofthewithin-groupsumsofsquaresandcross-productsmatrix.However,nagmvcanonvarcalculatesthecanonicalvariatesbymeansofasingularvalue position(SVD)ofamatrixV.Letthedatamatrixwithvariable(column)meanssubtractedbeX,andletitsrankbek;thenthekby(ng−1)matrixVisgivenby:

X

V=QTQg,whereQgisannby(ng1)orthogonalmatrixthatdefinesthegroupsandQXisthefirstkrowsoftheorthogonalmatrixQeitherfromtheQRpositionofX:

X=QR

ifXisoffullcolumnrank,i.e.,k=nx,elsefromtheSVDofX:

X=QDPT.

LettheSVDofVbe:

g

V=Ux∆UT

thenthenon-zeroelementsofthediagonalmatrix∆,δi,fori=1,2,...,l,arethelcanonicalcorrelationsassociatedwiththelcanonicalvariates,wherel=min(k,ng).

i

Theeigenvalues,λ2,ofthewithin-groupsumsofsquaresmatrixaregivenby:

δ

i

2

λ2= .

i 1 2

—δi

i

i

andthevalueofπi=λ2/Pλ2givestheproportionofvariationex inedbytheithcanonical

variate.Thevaluesoftheπi’sgiveanindicationastohowmanycanonicalvariatesareneededtoadequaydescribethedata,i.e.,thedimensionalityoftheproblem.

j

Totestforasignificantdimensionalitygreaterthanitheχ2statistic:

2

(n−1−ng−1(k−ng))

X

l

j=i+1

log(1+λ2)

− −−

canbeused.Thisisasymptoticallydistributedasaχ2distributionwith(ki)(ng1i)degreesofdom.Ifthetestfori=hisnotsignificant,thentheremainingtestsfori>hshouldbeignored.

TheloadingsforthecanonicalvariatesarecalculatedfromthematrixUx.Thismatrixisscaledsothatthecanonicalvariateshaveunitwithingroupvariance.

Inadditiontothecanonicalvariatesloadingsthemeansforeachcanonicalvariatearecalculatedforeachgroup.

Weightscanbeusedwiththeysis,inwhichcasetheweightedmeansaresubtractedfromeachcolumnandtheneachrowisscaledbyanamount√wi,wherewiistheweightfortheith

observation(row).

Parameters

weight

Input:indicatesthetypeofweightstobeusedintheysis.Ifweight=NagNoWeights,thennoweightsareused.

Ifweight=NagWeightsfreq,thentheweightsaretreatedasfrequenciesandtheeffectivenumberofobservationsisthesumoftheweights.

Ifweight=NagWeightsvar,thentheweightsaretreatedasbeinginverselyproportionaltothevarianceoftheobservationsandtheeffectivenumberofobservationsisthenumberofobservationswithnon-zeroweights.

Constraint:weight=NagNoWeights,NagWeightsfreqorNagWeightsvar.

n

Input:thenumberofobservations,n.Constraint:n≥nx+ng.

m

Input:thetotalnumberofvariables,m.Constraint:m≥nx.

x[n][tdx]

− −

Input:x[i 1][j 1]mustcontaintheithobservationforthejthvariable,fori=1,2,...,n;

j=1,2,...,m.

tdx

Input:thelastdimensionofthearrayxasdeclaredinthecallingprogram.Constraint:tdx≥m.

isx[m]

Input:isx[j−1]indicateswhetherornotthejthvariableistobeincludedinthe ysis.

Ifisx[j 1]>0,thenthevariablecontainedinthejthcolumnofxisincludedinthecanonicalvariate ysis,forj=1,2,...,m.

Constraint:isx[j−1]>0fornxvaluesofj.

nx

ing[n]

ng

Input:thenumberofvariablesintheysis,nx.Constraint:nx≥1.

Input:ing[i 1]indicateswhichgrouptheithobservationisin,fori=1,2,...,n.Theeffectivenumberofgroupsisthenumberofgroupswithnon-zeromembership.

Constraint:1≤ing[i−1]≤ng,fori=1,2,...,n.

Input:Thenumberofgroups,ng.Constraint:ng≥2.

wt[n]

Input:ifweight=NagWeightsfreqorNagWeightsvarthentheelementsofwtmustcontaintheweightstobeusedintheysis.

Ifwt[i−1]=0.0thentheithobservationisnotincludedinthe ysis.Constraints:

P

wt[i−1]≥0.0,fori=1,2,...,n,

ni=1

wt[i−1]≥nx+effectivenumberofgroups.

Note:Ifweight=NagNoWeightsthenwtisnotreferencedandmaybesettothenullpointer

NULL,i.e(double*)0.

nig[ng]

Output:nig[j−1]givesthenumberofobservationsingroupj,forj=1,2,...,ng.

cvm[ng][tdcvm]

− −

Output:cvm[i 1][j 1]containsthemeanofthejthcanonicalvariatefortheithgroup,fori=1,2,...,ng;j=1,2,...,l;theremainingcolumns,ifany,areusedasworkspace.

tdcvm

Input:thelastdimensionofthearraycvmasdeclaredinthecallingprogram.Constraint:tdcvm≥nx.

e[min(nx,ng-1)][tde]

Output:thestatisticsofthecanonicalvariateysis.

e[i−1][0],thecanonicalcorrelations,δi,fori=1,2,...,l.

i

e[i−1][1],theeigenvaluesofthewithin-groupsumofsquaresmatrix,λ2,fori=1,2,...,l.e[i−1][2],theproportionofvariationex inedbytheithcanonicalvariate,fori=1,2,...,l.e[i−1][3],theχ2statisticfortheithcanonicalvariate,fori=1,2,...,l.

e[i−1][4],thedegreesofdomforχ2statisticfortheithcanonicalvariate,fori=1,2,...,l.e[i1][5],thesignificancelevelfortheχ2statisticfortheithcanonicalvariate,fori=1,2,...,l.

tde

ncv

Input:thelastdimensionofthearrayeasdeclaredinthecallingprogram.Constraint:tde≥6.

Output:thenumberofcanonicalvariates,l.Thiswillbetheminimumofng 1andtherankofx.

cvx[nx][tdcvx]

− −

Output:thecanonicalvariaoadings.cvx[i1][j1]containstheloadingcoefficientfortheithvariableonthejthcanonicalvariate,fori=1,2,...,nx;j=1,2,...,l;theremainingcolumns,ifany,areusedasworkspace.

tdcvx

tol

Input:thelastdimensionofthearraycvxasdeclaredinthecallingprogram.Constraint:tdcvx≥ng−1.

Input:thevalueoftolisusedtodecideifthevariablesareoffullrankand,ifnot,whatistherankofthevariables.Thesmallerthevalueoftolthestricterthecriterionforselectingthesingularvalue position.Ifanon-negativevalueoftollessthanmachineprecisionisentered,thenthesquarerootofmachineprecisionisusedinstead.

Constraint:tol≥0.0.

irankx

Output:therankofthedependentvariables.

Ifthevariablesareoffullrankthenirankx=nx.

×

Ifthevariablesarenotoffullrankthenirankxisanestimateoftherankofthedependentvariables.irankxiscalculatedasthenumberofsingularvaluesgreaterthantol(largestsingularvalue).

NAGCLibraryManual

nagmvcanonvar

g03–MultivariateMethods

g03acc

3.g03acc.

PAGE

4

[NP3275/5/pdf]

[NP3275/5/pdf]

3.g03acc.

PAGE

5

fail

TheNAGerrorparameter,seetheEssentialIntroductiontotheNAGCLibrary.

ErrorIndicationsandWarnings

NEBADPARAM

Onentry,parameterweighthadanillegalvalue.

NEINTARGLT

Onentry,nxmustnotbelessthan1:nx=hvaluei.Onentry,ngmustnotbelessthan2:ng=hvaluei.Onentry,tdemustnotbelessthan6:tde=hvaluei.

NEREALARGLT

Onentry,tolmustnotbelessthan0.0:tol=hvaluei.

NE2INTARGLT

Onentry,m=hvalueiwhilenx=hvaluei.Theseparametersmustsatisfym≥nx.

Onentry,tdx=hvalueiwhilem=hvaluei.Theseparametersmustsatisfytdx≥m.

Onentry,tdcvx=hvalueiwhileng=hvaluei.Theseparametersmustsatisfytdcvx≥ng−1.Onentry,tdcvm=hvalueiwhilenx=hvaluei.Theseparametersmustsatisfytdcvm≥nx.

NE3INTARGCONS

Onentry,n=hvaluei,nx=hvalueiandng=hvaluei.Theseparametersmustsatisfyn≥nx+ng.

NEINTARRINT

Onentry,ing[hvaluei]=hvaluei,ng=hvaluei.Constraint:1≤ing[i−1]≤ng,i=1,2,...,n.

NEWTARGS

ThewtarrayargumentmustnotbeNULLwhentheweightargumentindicatesweights.

NENEGWEIGHEMENT

h i h i

Onentry,wt[value]=value.

Constraint:Whenreferenced,allelementsofwtmustbenon-negative.

NEVARINCLINDICATED

h i

h i

Thenumberofvariables,nxintheysis=value,whilenumberofvariablesincludedintheysisviaarrayisx=value.

Constraint:thesetwonumbersmustbethesame.

NESVDNOTCONV

Thesingularvalue positionhasfailedtoconverge.Thisisanunlikelyerrorexit.

NECANONCORR1

Acanonicalcorrelationisequaltoone.

Thiswillhappenifthevariablesprovideanexactindicationastowhichgroupeveryobservationisallocated.

NEGROUPS

Eithertheeffectivenumberofgroupsislessthantwoortheeffectivenumberofgroupsplusthenumberofvariables,nxisgreaterthanthetheeffectivenumberofobservations.

NERANKZERO

Therankofthevariablesiszero.

Thiswillhappenifallthevariablesareconstants.

NEALLOCFAIL

Memoryallocationfailed.

NEINTERNALERROR

Aninternalerrorhasoccurredinthisfunction.Checkthefunctioncallandanyarraysizes.IfthecalliscorrectthenpleaseconsultNAGforassistance.

FurtherComments

Accuracy

Asthecomputationinvolvestheuseoforthogonalmatricesandasingularvalue positionratherthanthetraditionalcomputingofasumofsquaresmatrixandtheuseofaneigenvalue

position,nagmvcanonvarshouldbelessaffectedbyillconditionedproblems.

References

ChatfieldCandCollinsAJ(1980)IntroductiontoMultivariateysisChapmanandHall.GnanadesikanR(1977)MethodsforStatisticalDataysisofMultivariateObservationsWiley.HrlingS(1985)Thesingularvalue positioninmultivariatestatisticsSIGNUM20(3)

2–25.

KendallMGandStuartA(1979)TheAdvancedTheoryofStatistics(3Volumes)Griffin(4thEdition).

SeeAlso

None.

Example

Asampleofnineobservations,eachconsistingofthreevariablesplusgroupindicator,isreadin.Therearethreegroups.Anunweightedcanonicalvariateysisisperformedandtheresultsprinted.

ProgramText

/*nag_mv_canon_var(g03acc)ExampleProgram.

*

Copyright1998NumericalAlgorithmsGroup.

*

Mark5,1998.

*/

#include<nag.h>#include<stdio.h>#include<nag_stdlib.h>#include<nagg03.h>

#defineNMAX9

#defineMMAX3

#defineTDE6

main()

{

doublee[MMAX][6];doublex[NMAX][MMAX];doublewt[NMAX];

doublecvm[MMAX][MMAX],tol,cvx[MMAX][MMAX];

Integeri,j,m,n;

Integerng;

Integernx;

Integering[NMAX],nig[MMAX],ncv;Integerirx,isx[2*MMAX];

Integertdx=MMAX,tdc=MMAX,tde=TDE;

charwtchar[2];Nag_Weightstypeweight;

NAGCLibraryManual

nagmvcanonvar

g03–MultivariateMethods

g03acc

3.g03acc.

PAGE

6

[NP3275/5/pdf]

[NP3275/5/pdf]

3.g03acc.

PAGE

7

Vprintf("g03accExampleProgramResults\n\n");

/* Skipheadingindatafile*/Vscanf("%*[^\n]");

Vscanf("%ld",&n);

Vscanf("%ld",&m);

Vscanf("%ld",&nx);

Vscanf("%ld",&ng);Vscanf("%s",wtchar);

if(n<=NMAX&&m<=MMAX)

{

if(*wtchar==’W’||*wtchar==’V’)

{

for(i=0;i<n;++i)

{

for(j=0;j<m;++j)Vscanf("%lf",&x[i][j]);

Vscanf("%lf",&wt[i]);

Vscanf("%ld",&ing[i]);

}

if(*wtchar==’W’)

weight=Nag_Weightsfreq;else

weight=Nag_Weightsvar;

}

else

{

for(i=0;i<n;++i)

{

for(j=0;j<m;++j)Vscanf("%lf",&x[i][j]);

Vscanf("%ld",&ing[i]);

}

weight=Nag_NoWeights;

}

for(j=0;j<m;++j)Vscanf("%ld",&isx[j]);

tol=1e-6;

g03acc(weight,n,m,(dou

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论