Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative contribution of covariates. R2, fraction of variance #68

Open
htansci opened this issue Dec 4, 2019 · 2 comments
Open

Relative contribution of covariates. R2, fraction of variance #68

htansci opened this issue Dec 4, 2019 · 2 comments

Comments

@htansci
Copy link

htansci commented Dec 4, 2019

Hello inlabru,

Is there an easy way to access a value of R2 from an lgcp() model fit with inlabru?

I am trying to assess the relative contribution of multiple covariates and was planning to do this by assessing changes in R2 after dropping covariates.

Also curious if there are more suitable approaches using this kind of model.

Cheers,

Harri

@finnlindgren
Copy link
Collaborator

R2 squared isn't defined for continuous domain LGCP models, so you'll need to define a different measure to use for this. You could perhaps consider assessing an R2-like measure based on discretised point counts? We have a brief discussion/example of assessing the contributions of spatial covariates and spatial random fields in the context of point process data in this paper: https://projecteuclid.org/euclid.aoas/1514430286
The approach used there can be computed with the help of calls to predict for models with and without the covariate one wants to assess the contribution of.

@htansci
Copy link
Author

htansci commented Dec 6, 2019

Ideally, the measure I would use would be somewhat analogous to the output of various SDM methods, perhaps something like a mean % contribution of each covariate to the linear predictor.

What I've come up with so far using predict() feels simple but I think it is something like what I want?

lp.pxl <- predict(fit.model, pxl, ~ spat + covar1 + covar2 + covar3, n.samples = 200)
lp.pxl.spat <- predict(fit.model, pxl, ~ spat, n.samples = 200)
lp.pxl.cov1 <- predict(fit.model, pxl, ~ covar1, n.samples = 200)
lp.pxl.cov2 <- predict(fit.model, pxl, ~ covar2, n.samples = 200)
lp.pxl.cov3 <- predict(fit.model, pxl, ~ covar3, n.samples = 200)

lp.pxl.spat$squared <-lp.pxl.cov3$mean^2
lp.pxl.cov1$squared <- lp.pxl.cov3$mean^2
lp.pxl.cov2$squared <- lp.pxl.cov3$mean^2
lp.pxl.cov3$squared <- lp.pxl.cov3$mean^2

lp.pxl$sumsquare <- lp.pxl.spat$squared + lp.pxl.cov1$squared + lp.pxl.cov2$squared + lp.pxl.cov3$squared

lp.pxl.spat$squared.frac.sumsq <- lp.pxl.spat$squared / lp.pxl$sumsquare
lp.pxl.cov1$squared.frac.sumsq <- lp.pxl.cov1$squared / lp.pxl$sumsquare
lp.pxl.cov2$squared.frac.sumsq <- lp.pxl.cov2$squared / lp.pxl$sumsquare
lp.pxl.cov3$squared.frac.sumsq <- lp.pxl.cov3$squared / lp.pxl$sumsquare

mean(lp.pxl.spat$squared.frac.sumsq)
mean(lp.pxl.cov1$squared.frac.sumsq)
mean(lp.pxl.cov2$squared.frac.sumsq)
mean(lp.pxl.cov3$squared.frac.sumsq)

Cheers,

Harri

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants