Class GWRMultiscale
Defined in File GWRMultiscale.h
Inheritance Relationships
Base Types
public gwm::SpatialMultiscaleAlgorithm
(Class SpatialMultiscaleAlgorithm)public gwm::IBandwidthSelectable
(Struct IBandwidthSelectable)public gwm::IRegressionAnalysis
(Struct IRegressionAnalysis)public gwm::IParallelizable
(Struct IParallelizable)public gwm::IParallelOpenmpEnabled
(Struct IParallelOpenmpEnabled)public gwm::IParallelCudaEnabled
(Struct IParallelCudaEnabled)public gwm::IParallelMpiEnabled
(Struct IParallelMpiEnabled)
Class Documentation
-
class GWRMultiscale : public gwm::SpatialMultiscaleAlgorithm, public gwm::IBandwidthSelectable, public gwm::IRegressionAnalysis, public gwm::IParallelizable, public gwm::IParallelOpenmpEnabled, public gwm::IParallelCudaEnabled, public gwm::IParallelMpiEnabled
Multiscale GWR Algorithm.
Public Types
-
enum BandwidthInitilizeType
Type of bandwidth initilization.
Values:
-
enumerator Null
-
enumerator Initial
-
enumerator Specified
-
enumerator Null
-
enum BandwidthSelectionCriterionType
Type of criterion for bandwidth selection.
Values:
-
enumerator CV
-
enumerator AIC
-
enumerator CV
-
enum BackFittingCriterionType
Type of criterion for backfitting convergence.
Values:
-
enumerator CVR
-
enumerator dCVR
-
enumerator CVR
-
typedef double (GWRMultiscale::* BandwidthSizeCriterionFunction)(BandwidthWeight*)
Function to calculate the criterion for given bandwidth size.
-
typedef arma::vec (GWRMultiscale::* FitVarFunction)(const size_t)
Function to fit a model for the given variable.
-
typedef arma::vec (GWRMultiscale::* FitVarCoreFunction)(const arma::vec&, const arma::vec&, const SpatialWeight&, arma::mat&)
Function to fit a model for the given variable.
-
typedef arma::vec (GWRMultiscale::* FitVarCoreCVFunction)(const arma::vec&, const arma::vec&, const SpatialWeight&)
Function to fit a model for the given variable.
-
typedef arma::vec (GWRMultiscale::* FitVarCoreSHatFunction)(const arma::vec&, const arma::vec&, const SpatialWeight&, arma::vec&)
Function to fit a model for the given variable.
Public Functions
-
inline GWRMultiscale()
Construct a new GWRMultiscale object.
-
inline GWRMultiscale(const arma::mat &x, const arma::vec &y, const arma::mat &coords, const std::vector<SpatialWeight> &spatialWeights)
Construct a new GWRMultiscale object.
- Parameters:
x – Independent variables.
y – Dependent variable.
coords – Coordinate matrix.
spatialWeights – Spatial weighting configuration.
-
inline virtual ~GWRMultiscale()
Destroy the GWRMultiscale object.
-
inline void setGoldenUpperBounds(double value)
Set the upper bounds of golden selection.
-
inline void setGoldenLowerBounds(double value)
Set the lower bounds of golden selection.
-
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 const std::vector<bool> &preditorCentered() const
Get whether preditors are centered.
- Returns:
std::vector<bool> Whether preditors are centered.
-
inline void setPreditorCentered(const std::vector<bool> &preditorCentered)
Set the Preditor Centered object.
- Parameters:
preditorCentered – Whether preditors are centered.
-
inline const std::vector<double> &bandwidthSelectThreshold() const
Get the threshold of bandwidth selection.
- Returns:
std::vector<double> Threshold of bandwidth selection.
-
inline void setBandwidthSelectThreshold(const std::vector<double> &bandwidthSelectThreshold)
Set the threshold of bandwidth selection.
- Parameters:
bandwidthSelectThreshold – Threshold of bandwidth selection.
-
inline bool hasHatMatrix() const
Get whether has hat matrix \(S\).
- Returns:
true Has hat matrix.
- Returns:
false Doesn’t have.
-
inline void setHasHatMatrix(bool hasHatMatrix)
Set whether has hat matrix \(S\).
- Parameters:
hasHatMatrix – Whether has hat matrix \(S\).
-
inline size_t bandwidthSelectRetryTimes() const
Get maximum retry times when select bandwidths.
- Returns:
size_t The maximum retry times when select bandwidths.
-
inline void setBandwidthSelectRetryTimes(size_t bandwidthSelectRetryTimes)
Set maximum retry times when select bandwidths.
- Parameters:
bandwidthSelectRetryTimes – The maximum retry times when select bandwidths.
-
inline size_t maxIteration() const
Get maximum iteration times.
- Returns:
size_t The maximum iteration times.
-
inline void setMaxIteration(size_t maxIteration)
Set maximum iteration times.
- Parameters:
maxIteration – The maximum iteration times.
-
inline BackFittingCriterionType criterionType() const
Get type of backfitting convergence criterion.
- Returns:
BackFittingCriterionType The type of backfitting convergence criterion.
-
inline void setCriterionType(const BackFittingCriterionType &criterionType)
Set type of backfitting convergence criterion.
- Parameters:
criterionType – The type of backfitting convergence criterion.
-
inline double criterionThreshold() const
Get threshold of criterion.
- Returns:
double The threshold of criterion.
-
inline void setCriterionThreshold(double criterionThreshold)
Set threshold of criterion.
- Parameters:
criterionThreshold – The threshold of criterion.
-
inline int adaptiveLower() const
Get lower bound for optimizing adaptive bandwidth.
- Returns:
int The lower bound for optimizing adaptive bandwidth.
-
inline void setAdaptiveLower(int adaptiveLower)
Set lower bound for optimizing adaptive bandwidth.
- Parameters:
adaptiveLower – The lower bound for optimizing adaptive bandwidth.
-
inline const arma::mat &betas() const
Get coefficient estimates \(\beta\).
- Returns:
arma::mat Coefficient estimates \(\beta\).
-
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.
-
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.
-
virtual void setSpatialWeights(const std::vector<SpatialWeight> &spatialWeights) override
Set the spatial weight configuration.
Use gwmodel_set_gwr_spatial_weight() to set this property to GWRBasic in shared build.
Use gwmodel_set_gwss_spatial_weight() to set this property to GWSS in shared build.
- Parameters:
spatialWeights – Reference of spatial weight configuration object.
-
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 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 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 virtual void setGPUId(const int gpuId) override
Set ID of used GPU while paralleling.
- Parameters:
gpuId – ID of used GPU. Start from 0.
-
inline virtual void setGroupSize(const std::size_t size) override
Set the group size while paralleling.
- Parameters:
size – Group size \(g\) while paralleling. Usually this is up to memory size \(m\) (B) of GPU with ID gpuId. If there are \(n\) samples and \(k\) variables,
\[ k * n * g * 8 < m \]For most GPU, 64 is OK.
-
inline virtual int workerId() override
-
inline virtual void setWorkerId(int id) override
-
inline virtual void setWorkerNum(int size) override
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.
-
static std::unordered_map<BackFittingCriterionType, std::string> BackFittingCriterionTypeNameMapper
A mapper from backfitting convergence criterion types to their names.
-
static int treeChildCount
Protected Functions
-
inline BandwidthWeight *bandwidth(size_t i)
Get the \(i\)-th bandwidth.
- Parameters:
i – The index of bandwidth.
- Returns:
BandwidthWeight* The \(i\)-th bandwidth.
-
arma::mat fitInitial()
-
arma::mat backfitting(const arma::mat &betas0)
The backfitting algorithm.
- Parameters:
x – Independent variables \(X\).
y – Dependent variable \(y\).
- Returns:
arma::mat Coefficient estimates \(\beta\).
-
arma::vec fitVarBase(const size_t var)
-
double bandwidthSizeCriterionVarCVBase(BandwidthWeight *bandwidthWeight)
The serial implementation of CV criterion calculator for given bandwidth size and one variable.
- Parameters:
bandwidthWeight – Badwidth weight.
- Returns:
double CV criterion value.
-
double bandwidthSizeCriterionVarAICBase(BandwidthWeight *bandwidthWeight)
The serial implementation of AIC criterion calculator for given bandwidth size and one variable.
- Parameters:
bandwidthWeight – Badwidth weight.
- Returns:
double AIC criterion value.
-
arma::vec fitVarCoreSerial(const arma::vec &x, const arma::vec &y, const SpatialWeight &sw, arma::mat &S)
The serial implementation of fit function for one variable.
- Parameters:
x – Independent variables \(X\).
y – Dependent variable \(y\).
var – The index of this variable.
S – The hat matrix \(S\).
- Returns:
arma::vec The coefficient estimates corresponding to this variable.
-
arma::vec fitVarCoreCVSerial(const arma::vec &x, const arma::vec &y, const SpatialWeight &sw)
-
arma::vec fitVarCoreSHatSerial(const arma::vec &x, const arma::vec &y, const SpatialWeight &sw, arma::vec &shat)
-
enum BandwidthInitilizeType