# setwd("C:/") # Y<-c(8.779557,8.411833,8.407378,8.36637,9.033604,7.999679,8.338066,10.30226,8.444622,9.011889,7.999679,7.855545,8.573573,8.213382,8.679312,9.12151,7.816014,8.338066,7.965546,8.850804,8.881836,8.716044,8.696176,8.644707,8.444622,8.095599,9.433484,8.407378,7.999679,8.361709,7.816014,8.26101,7.575585,7.969012,8.064636,8.402905,8.748305,7.807917,7.762171,8.271293,8.407378,8.961879,9.033604,8.338066,8.377932,8.472196,8.779557,7.783224,8.289037) X1<-c(4,6,6,10,8,6,4,2,9,7,8,7,8,9,7,6,2,7,8,6,5,2,4,2,5,7,7,2,7,7,6,4,4,2,7,4,10,7,4,8,8,7,8,7,8,7,8,3,8) X2<-c(4.033533,3.932022,4.094678,4.095677,4.569439,3.44967,3.954124,5.226606,4.114147,4.902605,3.447763,3.346037,4.207227,3.740048,4.354655,4.504908,3.316003,4.179451,3.619262,4.412798,4.416428,4.177613,4.35863,4.049696,4.170688,3.596764,4.874357,3.961765,3.714791,4.026423,3.385745,3.728821,3.144583,3.413126,3.713572,4.032115,4.253341,3.440098,3.690378,3.972742,3.941193,4.571717,4.532922,4.176385,4.176385,4.091006,4.398515,3.329343,4.059926) fx<-c(139.7162,139.7208,139.7219,139.7226,139.7232,139.7234,139.7244,139.7245,139.7252,139.7264,139.7273,139.7282,139.7284,139.7289,139.7294,139.7295,139.7297,139.7302,139.7308,139.7309,139.7309,139.7323,139.7326,139.7327,139.7333,139.7336,139.7341,139.7342,139.7344,139.7347,139.735,139.7355,139.7358,139.7362,139.7363,139.7363,139.7367,139.737,139.737,139.7372,139.7372,139.7374,139.7374,139.7377,139.7377,139.7383,139.7385,139.7386,139.7399) fy<-c(35.65771,35.66942,35.65763,35.65877,35.64232,35.65724,35.65306,35.654,35.63858,35.63617,35.65893,35.66432,35.67139,35.64004,35.64514,35.66937,35.64755,35.66809,35.63763,35.67094,35.64093,35.64315,35.63532,35.63883,35.63413,35.64534,35.63387,35.64103,35.66945,35.64472,35.66972,35.65321,35.64924,35.64534,35.65131,35.64474,35.64748,35.66719,35.63697,35.66306,35.66306,35.6463,35.6463,35.63458,35.63458,35.64717,35.64098,35.64583,35.64375) dat<-cbind(Y,X1,X2,fx,fy) library(spgwr) # OLS dat.ols<-lm(Y~X1 + X2) summary(dat.ols) # バンド幅の計算 dat.bw<-gwr.sel(Y~X1 + X2,coords=cbind(fx,fy)) # GWR dat.gauss<-gwr(Y~X1 + X2,coords=cbind(fx,fy),bandwidth=dat.bw,hatmatrix=TRUE) dat.gauss # str(dat.gauss) # 地理別係数の出力 predict.gauss<-dat.gauss[[1]] # predict.gauss # [1] --> sum.w # [2] --> X.Intercept. # [3] --> X1 # [4] --> X2 # [5] --> gwr.R2 # [6] --> X1 # [7] --> X2 # [8] --> X3 write.table(predict.gauss,file="predict.xls") # Testing LMZ.F3GWR.test(dat.gauss)