An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20080617/9fede8c1/attachment.pl>
Interpretation of gwr output ~ where is the fitted/predicted y?
6 messages · Debarchana Ghosh, Roger Bivand, Danlin Yu
On Tue, 17 Jun 2008, Debarchana Ghosh wrote:
Hi,
OS: 2.70 R version on Windows with 4 GB Ram
I have created an object of class gwr from the function 'gwr' (package
spgwr). But cannot find the fitted/predicted y values in the output.
test500.gwr <- gwr(formula = yimp00 ~ english + slope30 + mac95d + mdinc_t +
musa00 + popden_t + dissewer + dismcd + diswater +
ag04 +
c1dishwy + c1dipark + tccost1 + soil1 + soil2, data =
base500vars,
coords = cbind(base500vars$longx, base500vars$laty),
bandwidth = test500.bw.aic,
hatmatrix = TRUE, longlat = TRUE, se.fit = TRUE)
names(test500.gwr)
[1] "SDF" "lhat" "lm" "results" "bandwidth" "adapt" "hatmatrix" "gweight" "this.call"**
names(test500.gwr$SDF)
[1] "sumw" "Intercept" "english" "slope30" "mac95d" "mdinct" "musa00" "popdent" "dissewer" "dismcd" "diswater" [12] "ag04" "c1dishwy" "c1dipark" "tccost1" "soil1" "soil2" "R2" "gwre" "Interse" "englishse" "slope30se" [23] "mac95dse" "mdinctse" "musa00se" "popdentse" "dissewerse" "dismcdse" "diswaterse" "ag04se" "c1dishwyse" "c1diparkse" "tccost1se" [34] "soil1se" "soil2se" I want to clarify whether gwre ( previously it was gwr.e) is the estimated Y values?
No, gwr.e is (currently) the i'th element of the vector of residuals in each GWR (that is for each fit point). On examination, neither it nor the R2 has any meaning when the fit points are not identical with the data points - I will investigate and patch if need be. If data points are fit points, you can, perhaps, use it to get fitted values with the y values - as in CV bandwidth selection. What do you need them for? Hope this helps, Roger
Thanks, Debs.
Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20080618/ba9e2f95/attachment.pl>
Debarchana: As Roger has pointed out, since gwr.e is the gwr residuals, it is easy to calculate the estimated Y from the observed Y since residual = (observed Y) - (estimated Y). To extract the gwr.e, just do this: residuals.gwr<-test500.gwr$SDF$gwr.e and the estimated Y would be: est.gwr<-yimp00-residuals.gwr And then you can compare all Ys. Hope this helps. Cheers, Danlin
Debarchana Ghosh wrote:
I want to clarify whether gwre ( previously it was gwr.e) is the estimated
Y
values?
No, gwr.e is (currently) the i'th element of the vector of residuals in
each GWR (that is for each fit point). On examination, neither it nor the R2
has any meaning when the fit points are not identical with the data points -
I will investigate and patch if need be. If data points are fit points, you
can, perhaps, use it to get fitted values with the y values - as in CV
bandwidth selection. What do you need them for?
In the following gwr run, the fit.points are same as the given data points, i.e. the gwr regression is fitted on the points "coords = cbind(base500vars$longx, base500vars$laty)" , which was passed as an argument in the main gwr function and the fit.points argument was not specified. # gwr function test500.gwr<-gwr(yimp00~ english + slope30 + mac95d + mdinc_t + musa00 + popden_t + dissewer + dismcd + diswater + ag04 + c1dishwy + c1dipark + tccost1 + soil1 + soil2, data=base500vars, coords = cbind(base500vars$longx, base500vars$laty), longlat=TRUE, bandwidth = test500.bw.aic, hatmatrix=TRUE, se.fit=TRUE, gweight=bisquare) I did not understand how I can get the estimated y values as in CV bandwidth selection. Since my data points are same as the fitted points, I want to compare the 1) observed Y, 2) estimated Y from the OLS regression (lm object) and 3) estimated Y from the GWR regression (from the gwr object) Thanks, Debs.
___________________________________________ Danlin Yu, Ph.D. Assistant Professor Department of Earth & Environmental Studies Montclair State University Montclair, NJ, 07043 Tel: 973-655-4313 Fax: 973-655-4072 email: yud at mail.montclair.edu webpage: csam.montclair.edu/~yu
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20080618/5cac5d0b/attachment.pl>
On Wed, 18 Jun 2008, Debarchana Ghosh wrote:
I want to clarify whether gwre ( previously it was gwr.e) is the estimated Y values?
No, gwr.e is (currently) the i'th element of the vector of residuals in each GWR (that is for each fit point). On examination, neither it nor the R2 has any meaning when the fit points are not identical with the data points - I will investigate and patch if need be. If data points are fit points, you can, perhaps, use it to get fitted values with the y values - as in CV bandwidth selection. What do you need them for?
In the following gwr run, the fit.points are same as the given data points, i.e. the gwr regression is fitted on the points "coords = cbind(base500vars$longx, base500vars$laty)" , which was passed as an argument in the main gwr function and the fit.points argument was not specified. # gwr function test500.gwr<-gwr(yimp00~ english + slope30 + mac95d + mdinc_t + musa00 + popden_t + dissewer + dismcd + diswater + ag04 + c1dishwy + c1dipark + tccost1 + soil1 + soil2, data=base500vars, coords = cbind(base500vars$longx, base500vars$laty), longlat=TRUE, bandwidth = test500.bw.aic, hatmatrix=TRUE, se.fit=TRUE, gweight=bisquare) I did not understand how I can get the estimated y values as in CV bandwidth selection.
By arithmetic. If yi = yhati + ei, and you have yi (from the input data) and ei (from gwr.e), you can get yhati. I don't know what they give you, though, since they are dependent on the choice of kernel and bandwidth, as well as the relative arrangement of the data points, so they are just one of many possible sets of GWR fitted values. Roger PS. The erroneous local R2 and gwr.e where fit points are not data points will be removed from the results at the next release and replaced by NAs.
Since my data points are same as the fitted points, I want to compare the 1) observed Y, 2) estimated Y from the OLS regression (lm object) and 3) estimated Y from the GWR regression (from the gwr object) Thanks, Debs.
Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no