Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions include/gwmodelpp/GWRScalable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 获取计算优化参数指标值的类型。
*
Expand Down
16 changes: 16 additions & 0 deletions test/testGWRScalable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down