Dear Roger,

thanks so much for your answer. The  SpatialGridDataFrame was exactly what
I needed.
It,you helps me much.

Robert

-------------------------------------------------------
Robert Pazur<http://www.sav.sk/index.php?lang=sk&charset=&doc=user-org-user&user_no=6225>

Institute of Geography
Slovak Academy Of Sciences

Mobile : +421 948 001 705
Skype  : ruegdeg




2012/3/21 Roger Bivand <Roger.Bivand@nhh.no>

> On Wed, 21 Mar 2012, Robert Pazur wrote:
>
>  Dear all,
>>
>> i would like to perform rare events logistic regression with ASCII Grid
>> files.
>> For this purpose selected the *relogit* function from Zelig package.
>>
>>
>> I imported data into the R>
>>
>> library(maptools)
>> landcover <- data.frame(readAsciiGrid("
>> http://www.geography.sav.sk/**personal/pazur/data/ab.asc<http://www.geography.sav.sk/personal/pazur/data/ab.asc>
>> "))
>> temperature <- data.frame(readAsciiGrid("
>> http://www.geography.sav.sk/**personal/pazur/data/tem.asc<http://www.geography.sav.sk/personal/pazur/data/tem.asc>
>> "))
>> precipitation <- data.frame(readAsciiGrid("
>> http://www.geography.sav.sk/**personal/pazur/data/zr.asc<http://www.geography.sav.sk/personal/pazur/data/zr.asc>
>> "))
>>
>
> Your problem is not reading the documentation: ?readAsciiGrid says that it
> returns a SpatialGridDataFrame. You cannot use data.frame() to coerce this
> object to a data frame with just the data, as it takes care to return the
> coordinates as well. Isn't it simpler to do:
>
> library(maptools)
> site <- "http://www.geography.sav.sk/**personal/pazur/data/<http://www.geography.sav.sk/personal/pazur/data/>
> "
> landcover <- readAsciiGrid(paste(site, "ab.asc", sep=""))
> temperature <- readAsciiGrid(paste(site, "tem.asc", sep=""))
> precipitation <- readAsciiGrid(paste(site, "zr.asc", sep=""))
> SGDF <- cbind(landcover, temperature, precipitation)
> summary(SGDF)
>
> form <- formula(ab.asc ~ tem.asc + zr.asc)
> l.out <- glm(form, data=SGDF, family=binomial(link = "logit"))
> summary(l.out)
> SGDF$lfit <- fitted(l.out)
> library(Zelig)
> z.out <- zelig(form, data=SGDF, model="relogit")
> summary(z.out)
> SGDF$zfit <- c(fitted(z.out))
> spplot(SGDF, c("lfit", "zfit"), col.regions=bpy.colors(20))
>
> because the SpatialGridDataFrame object behaves just like a data.frame?
>
> Hope this clarifies,
>
> Roger
>
>
>> But it seems that this package (Zelig) cant handle spatial data. Is there
>> some straight way for transformation?
>>
>> Thanks in advance,
>> Kind regards,
>>
>> Robert Pazur
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________**_________________
>> R-sig-Geo mailing list
>> R-sig-Geo@r-project.org
>> https://stat.ethz.ch/mailman/**listinfo/r-sig-geo<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@nhh.no
>
>

	[[alternative HTML version deleted]]

