首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >返回在R中的地理加权回归的全局R2。

返回在R中的地理加权回归的全局R2。
EN

Stack Overflow用户
提问于 2017-05-12 00:42:09
回答 1查看 1K关注 0票数 3

我使用R库在spgwr中运行了一个地理加权回归(GWR),现在我想返回准全局R2 (模型的拟合)。我已经使用summary(gwr_model)深入研究了结果,但是我还没有找到提取这个值的方法。有什么想法吗?

可复制示例

代码语言:javascript
复制
library(spgwr)

# load data
  data(columbus)

# calculate Optimal kernel bandwidth 
  col.bw <- gwr.sel(crime ~ income + housing, data=columbus, coords=cbind(columbus$x, columbus$y))
# run GWR
  gwr_model <- gwr(crime ~ income + housing, data=columbus,
                   coords=cbind(columbus$x, columbus$y), bandwidth=col.bw, hatmatrix=TRUE)

# get global coefficients
  gwr_model$lm$coefficients


# print results. It shows the Quasi-global R2: 0.9071
  gwr_model

  #> Call:
  #>   gwr(formula = crime ~ income + housing, data = columbus, coords = cbind(columbus$x, 
  #>                                                                           columbus$y), bandwidth = col.bw, hatmatrix = TRUE)
  #> Kernel function: gwr.Gauss 
  #> Fixed bandwidth: 2.275 
  #> Summary of GWR coefficient estimates at data points:
  #>   Min. 1st Qu.  Median 3rd Qu.    Max. Global
  #> X.Intercept. 23.2332 54.1252 63.9024 68.7564 80.9009  68.62
  #> income       -3.1307 -1.9129 -0.9844 -0.3686  1.2911  -1.60
  #> housing      -1.0528 -0.3767 -0.0974  0.0301  0.7946  -0.27
  #> Number of data points: 49 
  #> Effective number of parameters (residual: 2traceS - traceS'S): 29.62 
  #> Effective degrees of freedom (residual: 2traceS - traceS'S): 19.38 
  #> Sigma (residual: 2traceS - traceS'S): 8.027 
  #> Effective number of parameters (model: traceS): 23.93 
  #> Effective degrees of freedom (model: traceS): 25.07 
  #> Sigma (model: traceS): 7.058 
  #> Sigma (ML): 5.049 
  #> AICc (GWR p. 61, eq 2.33; p. 96, eq. 4.21): 403.6 
  #> AIC (GWR p. 96, eq. 4.22): 321.7 
  #> Residual sum of squares: 1249 
  #> Quasi-global R2: 0.9071 
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-05-12 00:53:49

如果你想要的是得到“准全局R2",源代码表明至少可以计算它。

代码语言:javascript
复制
qGlobalR2 <- (1 - (gwr_model$results$rss/gwr_model$gTSS))
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43927662

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档