Changeset a3c9ab0 in tol


Ignore:
Timestamp:
Oct 21, 2008, 11:05:51 AM (18 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
41d9440
Parents:
e3f5af6
Message:

New method ModSes.Pri.Out.Comb.Create

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol/stdlib/math/stat/models/bayesian/bysMcmc/bsr/dynhlm/_db_api.tools.modses.pri.tol

    re3f5af6 ra3c9ab0  
    9595};
    9696
     97//////////////////////////////////////////////////////////////////////////////
     98/*
     99Implements an a priori node for combinatorial output:
     100
     101/Sum_j Y^{ij}*beta_j ~ N (mu_i, sigma_i).  j = 1, ....., m-parameters
     102                                           i = 1, .... , n-node equations
     103
     104Relevant arguments are:
     105
     106Set PriorInfo: Set of Sets, specifies the averages and sigma's of each node
     107               equation
     108               Set PriorInfo = [[   
     109                             [[  mu_1, sigma_1  ]],
     110                             [[  mu_2, sigma_2  ]],
     111                                  ...........
     112                             [[  mu_n, sigma_n  ]]
     113                     
     114                           ]]
     115
     116Set node_childs: Set Of NameBlocks, specifies the node and parameter's name of
     117                 each beta_j
     118
     119 Set  node_childs = [[
     120
     121       NameBlock  beta1 = [[  Text _.id_node =   , Text _.id_parameter=   ]],
     122       NameBlock  beta2 = [[  Text _.id_node =   , Text _.id_parameter=   ]],
     123       ................
     124       NameBlock  betaj = [[  Text _.id_node =   , Text _.id_parameter=   ]]
     125     
     126                    ]]   
     127
     128*/
     129Real ModSes.Pri.Out.Comb.Create(Text dbName,
     130                               Text model,
     131                               Text session,
     132                               Text id_node,
     133                               Text description,
     134                               Real number, 
     135                               Set  PriorInfo, // [[ [[ mu_1,sigma_1 ]],
     136                                               //    [[ mu_2,sigma_2 ]],
     137                                               //       ........... 
     138                                               // ]]
     139                               Set  node_childs, //Set de NameBlocks
     140                               Matrix Y)
     141//////////////////////////////////////////////////////////////////////////////
     142{
     143  Real ok = If(Card(node_childs)<1,
     144  {
     145    Text aux = If(Card(node_childs)," but one "," ");
     146    WriteLn("Cannot create prior node "+id_node+" due to related input"
     147    " is disabled along all"+aux+"child nodes","W");
     148    0
     149  },
     150  {
     151    WriteLn("Creating latent node "+id_node+" for "<<Rows(Y)+
     152            " observational nodes");
     153    Real ok.1 = ModSes.Node.Create
     154    (
     155      dbName, id_model, id_session, id_node,
     156      "PRI",
     157      888888888,
     158      number,
     159      description
     160    );
     161
     162    Real ok.2 = SetMin ( For (1, Rows(Y), Real (Real i){//ciclo ecuaciones nodo
     163          Real ModSes.Pri.Equ.Create (dbName, model, session, id_node,
     164                      i,
     165                      PriorInfo[i][1],
     166                      PriorInfo[i][2]);
     167                     
     168             Set For (1, Card(node_childs), Real (Real j){
     169                  NameBlock child = node_childs[j];
     170                  Real If (MatDat(Y,i,j)==0,0,   
     171                    Real ModSes.Pri.Output.Create(dbName, model, session,
     172                     id_node,
     173                     i,
     174                     child::_.id_node,
     175                     child::_.id_parameter,
     176                     MatDat(Y,i,j)) )
     177
     178              });
     179           1
     180        })); // Fin por ecuaciones nodo
     181        And(ok.1,ok.2)
     182   });  //Fin If ok
     183     Eval("ModSes.Pri.Out.Comb.Create."+id_node+".ok=ok")
     184}; // Fin de la funcion ModSes.Pri.Out.Comb.Create
     185Code PutDescription ("fulano",Code ModSes.Pri.Out.Comb.Create);
     186
Note: See TracChangeset for help on using the changeset viewer.