A.M. Xenaki
A.M. Xenaki

Reputation: 15

Is there a way to compute the standard error for GAM models using effectfun() within spatstat?

I am using spatstat version 3.0.2 to explore settlement patterns in archaeological data in five different periods throughout prehistory. I have formulated several point process models with different covariates including elevation, slope, etc. I started exploring GAM models and I would like to compare models that were not fitted using GAM with GAM models. I have a question as to the use of effectfun. Is there a way to compute the standard error of models fitted using GAM? The problem that I am facing is that effectfun does not show the standard error for models that were fit using GAM. So, for GAM models effectfun just provides me with the fitted line.

I have tried to recreate this problem with the bei dataset.

data(bei)
data(bei.extra)
elev <-  bei.extra$elev
fitNoGam <- ppm(bei~elev)
fitGam <- ppm(bei~s(elev),use.gam=TRUE)
par(mfrow=c(1,2))
plot(predict(fitNoGam))
plot(predict(fitGam))
plot(effectfun(fitNoGam,"elev",se.fit=T))
plot(effectfun(fitGam,"elev")) #does not allow the calculation of standard errors

In the effectfun plots it is clear that I can get the standard error for non GAM models through se.fit=T. Is there a way to compute the standard error for GAM models as well?

Upvotes: 0

Views: 151

Answers (1)

Adrian Baddeley
Adrian Baddeley

Reputation: 2973

You don't specify what you mean by "does not allow". It would be better to report the exact error message that you got from the software.

When I run your example code, there is an error message saying that the function s was not found. This is a bug. The bug can be traced to predict.ppm.

I have now fixed the bug in the development version of spatstat.model version 3.2-1.007 which you can download from the GitHub repository.

Upvotes: 1

Related Questions