Class GWDR

Inheritance Relationships

Base Types

Class Documentation

class GWDR : public gwm::SpatialAlgorithm, public gwm::IRegressionAnalysis, public gwm::IVarialbeSelectable, public gwm::IParallelizable, public gwm::IParallelOpenmpEnabled

Geographically Weighted Density Regression.

Public Types

enum BandwidthCriterionType

Type of bandwidth criterion.

Values:

enumerator CV

CV.

enumerator AIC

AIC.

typedef arma::mat (GWDR::* PredictCalculator)(const arma::mat&, const arma::mat&, const arma::vec&)

Calculator to predict.

typedef arma::mat (GWDR::* FitCalculator)(const arma::mat&, const arma::vec&, arma::mat&, arma::vec&, arma::vec&, arma::mat&)

Calculator to fit.

typedef double (GWDR::* BandwidthCriterionCalculator)(const std::vector<BandwidthWeight*>&)

Calculator to get criterion for bandwidth optimization.

typedef double (GWDR::* IndepVarCriterionCalculator)(const std::vector<std::size_t>&)

Calculator to get criterion for variable optimization.

Public Functions

inline GWDR()

Construct a new GWDR object.

inline GWDR(const arma::mat &x, const arma::vec &y, const arma::mat &coords, const std::vector<SpatialWeight> &spatialWeights, bool hasHatMatrix = true, bool hasIntercept = true)

Construct a new GWDR object. Independent variables Dependent variables Coordinates of samples Spatial weighting scheme Whether has hat matrix Whether has intercept.

inline virtual ~GWDR()

Destroy the GWDR object.

inline const arma::mat &betas() const

Get coefficient estimates. Coefficient estimates.

inline bool hasHatMatrix() const

Get whether has hat matrix. Yes No.

inline void setHasHatMatrix(bool flag)

Set whether has hat matrix. Whether has hat matrix.

inline const std::vector<SpatialWeight> &spatialWeights() const

Get spatial weighting scheme Spatial weighting scheme.

inline void setSpatialWeights(const std::vector<SpatialWeight> &spatialWeights)

Set spatial weighting scheme. Spatial weighting scheme.

inline bool enableBandwidthOptimize()

Get whether bandwidth optimization is enabled. Yes No.

inline void setEnableBandwidthOptimize(bool flag)

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

inline double bandwidthOptimizeEps() const

Get the threshold for bandwidth optimization. Threshold for bandwidth optimization.

inline void setBandwidthOptimizeEps(double value)

Set the threshold for bandwidth optimization. Threshold for bandwidth optimization.

inline std::size_t bandwidthOptimizeMaxIter() const

Get the maximum iteration for bandwidth optimization. Maximum iteration for bandwidth optimization.

inline void setBandwidthOptimizeMaxIter(std::size_t value)

Set the maximum iteration for bandwidth optimization. Maximum iteration for bandwidth optimization.

inline double bandwidthOptimizeStep() const

Get the step size for bandwidth optimization. Step size for bandwidth optimization.

inline void setBandwidthOptimizeStep(double value)

Set the step size for bandwidth optimization. Step size for bandwidth optimization.

inline BandwidthCriterionType bandwidthCriterionType() const

Get the type of criterion for bandwidth optimization. Type of criterion for bandwidth optimization.

void setBandwidthCriterionType(const BandwidthCriterionType &type)

Set the type of criterion for bandwidth optimization. Type of criterion for bandwidth optimization.

inline bool enableIndpenVarSelect() const

Get whether independent variable selection is enabled. Yes No.

inline void setEnableIndepVarSelect(bool flag)

Set whether independent variable selection is enabled. Whether independent variable selection is enabled.

inline double indepVarSelectThreshold() const

Get threshold for independent variable selection Threshold for independent variable selection.

inline void setIndepVarSelectThreshold(double threshold)

Set threshold for independent variable selection Threshold for independent variable selection.

inline const VariablesCriterionList &indepVarCriterionList() const

Get the list of criterion values for each variable combination in independent variable selection. List of criterion values for each variable combination in independent variable selection.

inline const std::vector<std::size_t> &selectedIndepVars() const

Get selected independent variable Selected independent variable.

inline arma::mat betasSE()

Get the standard error of coefficient estimates. Standard error of coefficient estimates.

inline arma::vec sHat()

Get a vector of trace of \(S\) and \(S'S\). A vector of trace of \(S\) and \(S'S\).

inline arma::vec qDiag()

Get the diagonal elements of matrix \(Q\). Diagonal elements of matrix \(Q\).

inline arma::mat s()

Get the hat matrix \(S\). Hat matrix \(S\).

virtual bool isValid() override

Check whether the algorithm’s configuration is valid.

Returns:

true if the algorithm’s configuration is valid.

Returns:

false if the algorithm’s configuration is invalid.

inline virtual const arma::vec &dependentVariable() const override

Get the Dependent Variable object.

Returns:

arma::vec Dependent Variable.

inline virtual void setDependentVariable(const arma::vec &y) override

Set the Dependent Variable object.

Parameters:

y

inline virtual const arma::mat &independentVariables() const override

Get the Independent Variables object.

Returns:

arma::mat Independent Variables.

inline virtual void setIndependentVariables(const arma::mat &x) override

Set the Independent Variables object.

Parameters:

x

inline virtual bool hasIntercept() const override

Get whether has intercept.

Returns:

true if has intercept.

Returns:

false if doesnot has intercept.

inline virtual void setHasIntercept(const bool has) override

Set the Has Intercept object.

Parameters:

has – true if has intercept, otherwise false.

inline virtual RegressionDiagnostic diagnostic() const override

Get diagnostic information.

Returns:

RegressionDiagnostic Diagnostic information.

inline 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

inline virtual Status getCriterion(const std::vector<std::size_t> &variables, double &criterion) override

Get criterion value with given variables for variable optimization.

Parameters:
  • variables – Given variables

  • criterion – [out] Criterion value.

Returns:

Status Algorithm status.

inline virtual std::vector<std::size_t> selectedVariables() override

Get selected variables.

Returns:

std::vector<std::size_t> Selected variables.

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 double bandwidthCriterion(const std::vector<BandwidthWeight*> &bandwidths)

Calculate criterion for given bandwidths. Given bandwidths Criterion value.

Public Static Functions

static RegressionDiagnostic CalcDiagnostic(const arma::mat &x, const arma::vec &y, const arma::mat &betas, const arma::vec &shat)

Calculate diagnostic information. Independent variables Dependent variables Coefficient estimates A vector of trace of \(S\) and \(S'S\) Diagnostic information.

static inline arma::vec Fitted(const arma::mat &x, const arma::mat &betas)

Get fitted value of dependent variable. Independent variables Coefficient estimates Fitted value of dependent variable.

static inline double RSS(const arma::mat &x, const arma::mat &y, const arma::mat &betas)

Get sum of squared residuals. Independent variables Dependent variables Coefficient estimates Sum of squared residuals.

static inline double AICc(const arma::mat &x, const arma::mat &y, const arma::mat &betas, const arma::vec &shat)

Get the corrected AIC value. Independent variables Dependent variables Coefficient estimates A vector of trace of \(S\) and \(S'S\).

Protected Functions

arma::mat predictSerial(const arma::mat &locations, const arma::mat &x, const arma::vec &y)

Non-parallel implementation of prediction function. Locations to predict Independent variables Dependent variables Coefficient estimates.

arma::mat fitSerial(const arma::mat &x, const arma::vec &y, arma::mat &betasSE, arma::vec &shat, arma::vec &qdiag, arma::mat &S)

Non-parallel implementation of fitting function. Independent variables Dependent variables [out] Standard error of coefficient estimates [out] A vector of trace of \(S\) and \(S'S\) [out] Diagonal elements of matrix \(Q\) [out] Hat matrix \(S\) Coefficient estimates.

double bandwidthCriterionAICSerial(const std::vector<BandwidthWeight*> &bandwidths)

Non-parallel implementation of calculator to get AIC criterion for given bandwidths. Given bandwidths Criterion value.

double bandwidthCriterionCVSerial(const std::vector<BandwidthWeight*> &bandwidths)

Non-parallel implementation of calculator to get CV criterion for given bandwidths. Given bandwidths Criterion value.

double indepVarCriterionSerial(const std::vector<std::size_t> &indepVars)

Non-parallel implementation of calculator to get AIC criterion for given variable combination. Given variable combination Criterion value.