Class GWRGeneralized

Inheritance Relationships

Base Types

Class Documentation

class GWRGeneralized : public gwm::GWRBase, public gwm::IBandwidthSelectable, public gwm::IParallelizable, public gwm::IParallelOpenmpEnabled

Generalized GWR.

Public Types

enum Family

Family of generalized model.

Values:

enumerator Poisson

Poisson model.

enumerator Binomial

Binomial model.

enum BandwidthSelectionCriterionType

Get type of criterion for bandwidth selection. BandwidthSelectionCriterionType Type of criterion for bandwidth selection.

Values:

enumerator AIC

AIC.

enumerator CV

CV.

typedef double (GWRGeneralized::* BandwidthSelectCriterionFunction)(BandwidthWeight*)

Calculator to get criterion for bandwidth optimization.

typedef arma::mat (GWRGeneralized::* GGWRfitFunction)(const arma::mat &x, const arma::vec &y)

Calculator for fitting.

typedef arma::vec (GWRGeneralized::* CalWtFunction)(const arma::mat &x, const arma::vec &y, arma::mat w)

Calculator for weighting.

Public Functions

inline GWRGeneralized()

Construct a new GWRGeneralized object.

inline ~GWRGeneralized()

Destroy the GWRGeneralized object.

inline virtual Status getCriterion(BandwidthWeight *bandwidthWeight, double &criterion) override

Get criterion value with given bandwidth for bandwidth optimization.

Parameters:
  • weight – Given bandwidth.

  • criterion – [out] Criterion value.

Returns:

Status Algorithm status.

virtual arma::mat predict(const arma::mat &locations) override

Predict coefficients on specified locations.

Parameters:

locations – Locations where to predict coefficients.

Returns:

mat Predicted coefficients.

virtual arma::mat fit() override

Fit coefficient estimates.

Returns:

mat Coefficient estimates

arma::mat fit(const arma::mat &x, const arma::vec &y, arma::mat &betasSE, arma::vec &shat, arma::vec &qdiag, arma::mat &S)
inline virtual int parallelAbility() const override

Return the parallel ability of this algorithm.

Returns:

Bitwise OR of aviliable parallel types of this algorithm.

inline virtual ParallelType parallelType() const override

Return the parallel type of this algorithm.

Returns:

Parallel type of this algorithm

virtual void setParallelType(const ParallelType &type) override

Set the parallel type of this algorithm.

Parameters:

type – Parallel type of this algorithm.

inline virtual void setOmpThreadNum(const int threadNum) override

Set the thread numbers while paralleling.

Parameters:

threadNum – Number of threads.

inline Family getFamily() const

Get the family of the model. Family of the model.

bool setFamily(Family family)

Set the family of the model. Family of the model.

inline double getTol() const

Get the tolerance. Tolerance.

inline void setTol(double tol)

Set the tolerance. Tolerance.

inline size_t getMaxiter() const

Get the maximum of iteration. Maximum of iteration.

inline void setMaxiter(std::size_t maxiter)

Set the maximum of iteration. Maximum of iteration.

inline const arma::mat &getWtMat1() const
inline const arma::mat &getWtMat2() const
inline GWRGeneralizedDiagnostic getDiagnostic() const

Get the diagnostic information. Diagnostic information.

inline GLMDiagnostic getGLMDiagnostic() const

Get the diagnostic information of generalized linear model. Diagnostic information.

void setBandwidthSelectionCriterionType(const BandwidthSelectionCriterionType &bandwidthSelectionCriterionType)
inline BandwidthCriterionList bandwidthSelectorCriterions() const
inline BandwidthSelectionCriterionType bandwidthSelectionCriterionType() const
inline bool autoselectBandwidth() const

Get whether bandwidth optimization is enabled. Yes No.

inline void setIsAutoselectBandwidth(bool value)

Set whether bandwidth optimization is enabled. Whether bandwidth optimization is enabled.

inline arma::mat regressionData() const
inline void setRegressionData(const arma::mat &locations)
inline bool hasHatMatrix() const

Get whether has hat matrix. Yes No.

inline void setHasHatMatrix(bool value)

Set whether has hat matrix. Whether has hat matrix.

inline bool hasRegressionData() const
inline void setHasRegressionData(bool value)

Public Members

BandwidthCriterionList mBandwidthSelectionCriterionList

Public Static Functions

static arma::vec gwPredict(const arma::mat &x, const arma::vec &y, const arma::vec &w)

Geographically weighted predicting. Independent variables Dependent variables Weights Coefficient estimates.

static arma::vec gwFit(const arma::mat &x, const arma::vec &y, const arma::vec &w, arma::uword focus, arma::mat &ci, arma::mat &s_ri)

Geographically weighted fitting. Independent variables Dependent variables Weights Index of focused sample Coefficient estimates.

static arma::mat dpois(arma::mat y, arma::mat mu)
static arma::mat dbinom(arma::mat y, arma::mat m, arma::mat mu)
static arma::mat lchoose(arma::mat n, arma::mat k)
static arma::mat lgammafn(arma::mat x)
static arma::mat CiMat(const arma::mat &x, const arma::vec &w)

Protected Functions

arma::mat fitPoissonSerial(const arma::mat &x, const arma::vec &y)

Serial implementation of fitting Poisson model. Independent variables Dependent variables Coefficient estimates.

arma::mat fitBinomialSerial(const arma::mat &x, const arma::vec &y)

Serial implementation of fitting Binomial model. Independent variables Dependent variables Coefficient estimates.

arma::mat diag(arma::mat a)
arma::vec PoissonWtSerial(const arma::mat &x, const arma::vec &y, arma::mat w)

Serial implementation of fitting weighted Poisson model. Independent variables Dependent variables Weights Coefficient estimates.

arma::vec BinomialWtSerial(const arma::mat &x, const arma::vec &y, arma::mat w)

Serial implementation of fitting weighted Binomial model.

void CalGLMModel(const arma::mat &x, const arma::vec &y)

Protected Attributes

Family mFamily

Family of the model.

double mTol = 1e-5

Tolerance.

std::size_t mMaxiter = 20

Maximum of iteration.

bool mHasHatMatrix = true

Whether has hat matrix.

bool mHasRegressionData = false
arma::mat mBetasSE

//!< Standard error of coefficient estimates

arma::vec mShat

//!< A vector of trace of \(S\) and \(S'S\)

arma::mat mS

//!< Hat matrix \(S\)

double mGwDev
arma::mat mRegressionData
arma::mat mWtMat1
arma::mat mWtMat2
GWRGeneralizedDiagnostic mDiagnostic

Diagnostic information.

GLMDiagnostic mGLMDiagnostic

Diagnostic information for GLM.

arma::mat mWt2
arma::mat myAdj
double mLLik = 0

Logorithm of likelihood.

GGWRfitFunction mGGWRfitFunction = &GWRGeneralized::fitPoissonSerial

Calculator for fitting.

CalWtFunction mCalWtFunction = &GWRGeneralized::PoissonWtSerial

Calculator for weighting.

bool mIsAutoselectBandwidth = false

Whether bandwidth optimization is enabled.

BandwidthSelectionCriterionType mBandwidthSelectionCriterionType = BandwidthSelectionCriterionType::AIC

Type of criterion for bandwidth optimization.

BandwidthSelectCriterionFunction mBandwidthSelectCriterionFunction = &GWRGeneralized::bandwidthSizeGGWRCriterionCVSerial

Calculator to get criterion for given bandwidth value.

BandwidthSelector mBandwidthSizeSelector

Bandwidth size selector.

double mBandwidthLastCriterion = DBL_MAX

Last criterion for bandwidth selection.

ParallelType mParallelType = ParallelType::SerialOnly

Type of parallelization.

int mOmpThreadNum = 8

Number of threads used in multithreading.