当前位置: 首页>>代码示例>>C++>>正文


C++ AVector::rows方法代码示例

本文整理汇总了C++中AVector::rows方法的典型用法代码示例。如果您正苦于以下问题:C++ AVector::rows方法的具体用法?C++ AVector::rows怎么用?C++ AVector::rows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AVector的用法示例。


在下文中一共展示了AVector::rows方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: rcpp_model


//.........这里部分代码省略.........
         // get the mode for beta given the mode of the approximated marginal posterior as z
         // if TBF approach is used, this will be the only time the IWLS is used,
         // because we only need the MLE and the Cholesky factor of its
         // precision matrix estimate, which do not depend on z.
         PosInt iwlsIterations = fitter.iwlsObject->startWithNewLinPred(40,
                                                                        // this is the corresponding g
                                                                        exp(startZ),
                                                                        // and the start value for the linear predictor is taken from the Glm model config
                                                                        config.linPredStart);

         // echo debug-level message?
         if(options.debug)
         {
             Rprintf("\ncpp_sampleGlm: Initial IWLS for high density point finished after %d iterations",
                     iwlsIterations);
         }

         // this is the current proposal info:
         now.proposalInfo = fitter.iwlsObject->getResults();

         // and this is the current parameters sample:
         now.sample = Parameter(now.proposalInfo.coefs,
                                startZ);

         if(options.tbf)
         {
             // we will not compute this in the TBF case:
             now.logUnPosterior = R_NaReal;

             // start to compute the variance of the intercept parameter:

             // here the inverse cholesky factor of the precision matrix will
             // be stored. First, it's the identity matrix.
             AMatrix inverseQfactor = arma::eye(now.proposalInfo.qFactor.n_rows,
                                                now.proposalInfo.qFactor.n_cols);

             // do the inversion
             trs(false,
                 false,
                 now.proposalInfo.qFactor,
                 inverseQfactor);

             // now we can compute the variance of the intercept estimate:
             const AVector firstCol = inverseQfactor.col(0);
             const double interceptVar = arma::dot(firstCol, firstCol);

             // ok, now alter the qFactor appropriately to reflect the
             // independence assumption between the intercept estimate
             // and the other coefficients estimates
             now.proposalInfo.qFactor.col(0) = arma::zeros<AVector>(now.proposalInfo.qFactor.n_rows);
             now.proposalInfo.qFactor(0, 0) = sqrt(1.0 / interceptVar);
         }
         else
         {
             // compute the (unnormalized) log posterior of the proposal
             now.logUnPosterior = fitter.iwlsObject->computeLogUnPosteriorDens(now.sample);
         }
     }
     else
     {
         PosInt coxfitIterations = fitter.coxfitObject->fit();
         CoxfitResults coxResults = fitter.coxfitObject->finalizeAndGetResults();
         fitter.coxfitObject->checkResults();

         // echo debug-level message?
         if(options.debug)
开发者ID:rforge,项目名称:bfp,代码行数:67,代码来源:sampleGlm.cpp


注:本文中的AVector::rows方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。