Class GWCorrelation

Inheritance Relationships

Base Types

Class Documentation

class GWCorrelation : public gwm::SpatialMultiscaleAlgorithm, public gwm::IMultivariateAnalysis, public gwm::IParallelizable, public gwm::IParallelOpenmpEnabled, public gwm::IBandwidthSelectable

The class for Geographically Weighted Correlation. Geographically Weighted Correlation is an algorithm for calculating local weighted statistics. They are local covariances, local correlations (Pearson’s), local correlations (Spearman’s), local medians, local interquartile ranges, local quantile imbalances and coordinates. To get these matrices, call these functions:

Public Types

enum BandwidthInitilizeType

Type of bandwidth initilization.

Values:

enumerator Null
enumerator Initial
enumerator Specified
enum BandwidthSelectionCriterionType

Type of criterion for bandwidth selection.

Values:

enumerator CV
enumerator AIC
typedef void (GWCorrelation::* SummaryCalculator)()

Calculator for GWCorrelation.

typedef double (GWCorrelation::* BandwidthSizeCriterionFunction)(BandwidthWeight*)

Function to calculate the criterion for given bandwidth size.

typedef double (GWCorrelation::* BandwidthSelectionCriterionCalculator)(BandwidthWeight*)

Declaration of criterion calculator for bandwidth selection.

Public Functions

inline GWCorrelation()

Construct a new GWCorrelation object.

inline ~GWCorrelation()

Destroy the GWCorrelation object.

inline const arma::mat &localMean() const

Get local mean on each sample. Local mean on each sample.

inline const arma::mat &localSDev() const

Get local standard deviation on each sample. Local standard deviation on each sample.

inline const arma::mat &localSkewness() const

Get local skewness on each sample. Local skewness on each sample.

inline const arma::mat &localCV() const

Get local coefficients of variation on each sample. Local coefficients of variation on each sample.

inline const arma::mat &localVar() const

Get local variance on each sample. Local variance on each sample.

inline const arma::mat &localCov() const

Get local coefficients of variation on each sample. Local coefficients of variation on each sample. If corrWithFirstOnly is set true, the number of columns is the (number of fields) - 1; if not, the number of columns is the (((number of fields) - 1) * (number of fields)) / 2. For variables \(v_1, v_2, v_3, ... , v_{k-1}, v_k\), the fields are arranged as: \(cov(v_1,v_2), cov(v_1,v_3), ... , cov(v_1,v_k), cov(v_2,v_3), ... , cov(v_2,v_k), ... , cov(v_{k-1},vk)\).

inline const arma::mat &localCorr() const

Get local correlations (Pearson’s) on each sample. Local correlations (Pearson’s) on each sample. If corrWithFirstOnly is set true, the number of columns is the (number of fields) - 1; if not, the number of columns is the (((number of fields) - 1) * (number of fields)) / 2. For variables \(v_1, v_2, v_3, ... , v_{k-1}, v_k\), the fields are arranged as: \(corr(v_1,v_2), corr(v_1,v_3), ... , corr(v_1,v_k), corr(v_2,v_3), ... , corr(v_2,v_k), ... , corr(v_{k-1},vk)\).

inline const arma::mat &localSCorr() const

Get local correlations (Spearman’s) on each sample. Local correlations (Spearman’s) on each sample. If corrWithFirstOnly is set true, the number of columns is the (number of fields) - 1; if not, the number of columns is the (((number of fields) - 1) * (number of fields)) / 2. For variables \(v_1, v_2, v_3, ... , v_{k-1}, v_k\), the fields are arranged as: \(corr(v_1,v_2), corr(v_1,v_3), ... , corr(v_1,v_k), corr(v_2,v_3), ... , corr(v_2,v_k), ... , corr(v_{k-1},vk)\).

inline bool isAutoselectBandwidth()
inline const std::vector<BandwidthInitilizeType> &bandwidthInitilize() const

Get the type of bandwidth initilization.

Returns:

std::vector<BandwidthInitilizeType> The type of bandwidth initilization

void setBandwidthInitilize(const std::vector<BandwidthInitilizeType> &bandwidthInitilize)

Set the bandwidth initilization type.

Parameters:

bandwidthInitilize – The type of bandwidth initilization

inline const std::vector<BandwidthSelectionCriterionType> &bandwidthSelectionApproach() const

Get the bandwidth selection approach.

Returns:

std::vector<BandwidthSelectionCriterionType> Bandwidth selection approach.

void setBandwidthSelectionApproach(const std::vector<BandwidthSelectionCriterionType> &bandwidthSelectionApproach)

Set the bandwidth selection approach.

Parameters:

bandwidthSelectionApproach – Bandwidth selection approach.

inline BandwidthSizeCriterionFunction bandwidthSizeCriterionVar(BandwidthSelectionCriterionType type)

Get criterion calculator function for optimize bandwidth size for one variable.

Parameters:

type – The criterion type for optimize bandwidth size for one variable.

Returns:

BandwidthSizeCriterionFunction The criterion calculator for optimize bandwidth size for one variable.

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

Get criterion value with given bandwidth for bandwidth optimization.

Parameters:
  • weight – Given bandwidth.

  • criterion – [out] Criterion value.

Returns:

Status Algorithm status.

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.

Use setParallelType to set parallel type of this algorithm to ParallelType::OpenMP in shared build.

Parameters:

type – Parallel type of this algorithm.

inline virtual void setOmpThreadNum(const int threadNum) override

Set the thread numbers while paralleling.

Use gwmodel_set_GWAverage_openmp() to set this property in shared build.

Parameters:

threadNum – Number of threads.

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::mat &variables2() const override

Get variables.

Returns:

arma::mat of variables.

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

set variables variables for GWAverage

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

Get response variables.

Returns:

arma::mat of variables.

inline virtual void setVariables1(const arma::mat &y) override

set variables variables for GWAverage

virtual void run() override

Run analysis algorithm.

void calibration(const arma::mat &locations, const arma::mat &x)

Public Static Functions

static inline double covwt(const arma::mat &x1, const arma::mat &x2, const arma::vec &w)

Calculate weighted covariances for two matrices. Matrix \( X_1 \) Matrix \( X_2 \) Weight vector \( w \) Weighted covariances.

\[ cov(X_1,X_2) = \frac{\sum_{i=1}^n w_i(x_{1i} - \bar{x}_1) \sum_{i=1}^n w_i(x_{2i} - \bar{x}_2)}{1 - \sum_{i=1}^n w_i} \]

static inline double corwt(const arma::mat &x1, const arma::mat &x2, const arma::vec &w)

Calculate weighted correlation for two matrices. Matrix \( X_1 \) Matrix \( X_2 \) Weight vector \( w \) Weighted correlation.

\[ corr(X_1,X_2) = \frac{cov(X_1,X_2)}{\sqrt{cov(X_1,X_1) cov(X_2,X_2)}} \]
加权相关系数
\[ corr(X_1,X_2) = \frac{cov(X_1,X_2)}{\sqrt{cov(X_1,X_1) cov(X_2,X_2)}} \]

static inline arma::vec rank(arma::vec x)
static arma::vec del(arma::vec x, arma::uword rowcount)

Public Static Attributes

static std::unordered_map<BandwidthInitilizeType, std::string> BandwidthInitilizeTypeNameMapper

A mapper from bandwidth inilization types to their names.

static std::unordered_map<BandwidthSelectionCriterionType, std::string> BandwidthSelectionCriterionTypeNameMapper

A mapper from bandwidth selection criterion types to their names.

Protected Functions

inline BandwidthWeight *bandwidth(size_t i)