source: tol/tol_pkg/BysVecLinReg/test/test_0001/test.tol @ 5633d43

1941-docker-image-to-testdevel
Last change on this file since 5633d43 was 5633d43, checked in by Víctor de Buen <vdebuen@…>, 16 years ago

Se añade el fichero tools para las funciones de utilidad general
Nueva función eqConstrainedStdGaussian para la generación de multinormales con restricciones lineales de igualdad

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@2148 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/* -*- mode: C++ -*- */
2//////////////////////////////////////////////////////////////////////////////
3// FILE   : test.tol
4//////////////////////////////////////////////////////////////////////////////
5
6
7Text email_ = "vdebuen@tol-project.org";
8Text link_ = "";
9Text summary_ =
10"test_0001 multivariate linear model with known covariance matrix" ;
11
12Real numErr0 = Copy(NError);
13
14#Embed "../gen_multivariant_linear_regression.tol";
15
16
17BysVecLinReg::@Multivariate MV = [[
18  Text _.desc = "Modelo lineal multivariante para ventas de Fanta en Turquía",
19  Set _.outputNames = For(1,d,Text(Real i) { "Output_"<<i }),
20  Set _.inputNames = For(1,m,Text(Real i) { "Input_"<<i })
21]];
22
23Real MV::set.outputInput(Y,X);
24Real MV::change.V(V);
25
26VMatrix S = KroneckerProduct(V,MtMSqr(MV::_.X.Li));
27VMatrix L = Tra(MV::_.IdxXLi) * MV::_.VxIm.Le;
28VMatrix LLt = MMtSqr(L);
29
30Real ok_.X.Li = VMatMax(Abs((MV::_.X.Li * MV::_.X.Le+m*N)-m*N - Eye(m)))==0;
31Real ok_.IdxXL = VMatMax(Abs((Tra(MV::_.IdxXL)*S*MV::_.IdxXL - MV::_.VxIm+m*d)-m*d))==0;
32Real ok_.IdxXLi = VMatMax(Abs((MV::_.IdxXLi * MV::_.IdxXL+m*N)-m*N - Eye(m*d)))==0;
33Real okLLt = VMatMax(Abs((LLt-S+m*N)-m*N ))==0;
34
35VMatrix mcmc = Group("ConcatRows", For(1,sampleLength,VMatrix(Real numSim)
36{
37  Tra(MV::gibbs.draw.vec.A(0))
38}));
39
40VMatrix vec.A_ = Tra(Constant(1,sampleLength,1/sampleLength)*mcmc);
41VMatrix vec.A = BysVecLinReg::vmatrix2vec(A);
42VMatrix cmp.A = vec.A | vec.A_;
43
44VMatrix A_ = BysVecLinReg::vec2vmatrix(vec.A_,A);
45VMatrix E_ = Y - A_*X;
46VMatrix E01_ = CholeskiSolve(V.L,E_,"PtLLtP");
47VMatrix cmpE01 = BysVecLinReg::vmatrix2vec(E01) |
48                 BysVecLinReg::vmatrix2vec(E01_);
49
50Real stdErr  = VMatAvr(E01 ^2);
51Real stdErr_ = VMatAvr(E01_^2);
52
53Real numErr1 = Copy(NError);
54
55//Extented information about test behaviour
56Set partialResults_ =
57[[
58  numErr0, numErr1, stdErr, stdErr_,
59  ok_.X.Li, ok_.IdxXL, ok_.IdxXLi, okLLt
60
61]];
62
63Real quality_ = And(
64  numErr1==numErr0,
65  ok_.X.Li, ok_.IdxXL, ok_.IdxXLi, okLLt)*
66  Min(1,Exp((stdErr-stdErr_)*N*d));
67
68//Return the results
69Set resultStr_ = @strTestStatus(summary_, link_, quality_,
70                  "Partial results = "<<partialResults_,
71                  "NO DBServerType", "NO DBServerHost", "NO DBAlias",
72                  email_);
73WriteLn(""<<resultStr_);
74resultStr_
75
76/* */
77
78
79/* */
Note: See TracBrowser for help on using the repository browser.