diff --git a/include/gwmodelpp/GWRScalable.h b/include/gwmodelpp/GWRScalable.h index 8a97de7..0e56a1a 100644 --- a/include/gwmodelpp/GWRScalable.h +++ b/include/gwmodelpp/GWRScalable.h @@ -146,6 +146,20 @@ class GWRScalable : public GWRBase */ void setHasHatMatrix(const bool has) { mHasHatMatrix = has; } + /** + * @brief \~english Get standard errors of coefficient estimates. \~chinese 获取回归系数估计值的标准差。 + * + * @return arma::mat \~english Standard errors of coefficient estimates. \~chinese 回归系数估计值的标准差。 + */ + const arma::mat& betasSE() const { return mBetasSE; } + + /** + * @brief \~english Get a vector of \f$tr(S)\f$ and \f$tr(SS^T)\f$. \~chinese 获取一个由 \f$tr(S)\f$ 和 \f$tr(SS^T)\f$ 组成的向量。 + * + * @return arma::vec \~english A vector of \f$tr(S)\f$ and \f$tr(SS^T)\f$. \~chinese 由 \f$tr(S)\f$ 和 \f$tr(SS^T)\f$ 组成的向量。 + */ + const arma::vec& sHat() const { return mShat; } + /** * @brief \~english Get the type of calculator for parameter optimization criterion. \~chinese 获取计算优化参数指标值的类型。 * diff --git a/test/testGWRScalable.cpp b/test/testGWRScalable.cpp index c89c854..5b6cf52 100644 --- a/test/testGWRScalable.cpp +++ b/test/testGWRScalable.cpp @@ -122,6 +122,22 @@ TEST_CASE("ScableGWR: autoselection with CV") REQUIRE(algorithm.hasIntercept() == true); + // Test sHat() and betasSE() getters + vec shat = algorithm.sHat(); + mat betasSE = algorithm.betasSE(); + double cv = algorithm.cv(); + + std::cout << "\n=== ScalableGWR Intermediate Results ===" << std::endl; + std::cout << "CV (Cross-Validation) value: " << cv << std::endl; + std::cout << "sHat values: tr(S)=" << shat(0) << ", tr(S'S)=" << shat(1) << std::endl; + std::cout << "betasSE shape: " << betasSE.n_rows << " x " << betasSE.n_cols << std::endl; + std::cout << "betasSE first row: " << betasSE.row(0) << std::endl; + std::cout << "betasSE values (全部):\n" << betasSE << std::endl; + + REQUIRE(shat.n_rows == 2); + REQUIRE(betasSE.n_rows > 0); + REQUIRE(betasSE.n_cols > 0); + } TEST_CASE("Scalable GWR: cancel")