[R-sig-Geo] FW: GWAR - R
Roger Bivand
Roger.Bivand at nhh.no
Sun Sep 25 12:37:46 CEST 2011
On Sun, 25 Sep 2011, Inaki Sagarzazu wrote:
> Hi Roger
>
> Thanks for your response. I am not sure why there can't be polygons with
> missing info. Is it something with the model or the estimation?
You cannot fit a linear model with missing info either, those cases get
dropped.
>
> Also, How can I drop the NA's from a shape file in R? I've tried but
> can't seem to be able to do it.
>
Assuming that the data only contain variables that are relevant for the
model, create a logical vector and subset in the usual way:
cc <- complete.cases(as(myshp, "data.frame"))
myshp_cc <- myshp[cc,]
If there are other unused variables with NAs that may lead you to drop
more observations than necessary, create a new object with only the
relevant columns first:
names(myshp0)
myshp <- myshp0[, c(1,3,5,7)]
if c(1,3,5,7) are the variables you want - you can use names in a vector
too.
Hope this helps,
Roger
> Thanks
>
> Inaki
>
> On 24 Sep 2011, at 08:27, "Roger Bivand" <Roger.Bivand at nhh.no> wrote:
>
>> On Thu, 22 Sep 2011, Inaki Sagarzazu wrote:
>>
>>>
>>> Hi,
>>>
>>> I am trying to use gwr in R but I'm having problems because some of my
>>> polygons have missing values (NA) for the variables of interest. Do you
>>> have any suggestions on how to solve this?
>>
>> If data is missing in the response or covariates, all bets are off. You
>> could drop those observations, or incomplete variables. You could try to
>> impute the values, but then standard results would not hold downstream.
>>
>> Roger
>>
>>>
>>> thanks
>>>
>>> ---------------------------------------------------------------------------------------------------------------
>>> Iñaki Sagarzazu, PhD
>>> Research Officer
>>> Nuffield College
>>> University of Oxford
>>> OX1 1NF Oxford
>>> United Kingdom
>>>
>>> Office: 44 (0) 1 865 614990
>>> Inaki.Sagarzazu at nuffield.ox.ac.uk
>>> http://www.inaki-sagarzazu.com
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> R-sig-Geo at r-project.org
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>
>>
>> --
>> Roger Bivand
>> Department of Economics, NHH Norwegian School of Economics,
>> 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
>
--
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
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
More information about the R-sig-Geo
mailing list