margins icon indicating copy to clipboard operation
margins copied to clipboard

Support for mgcv::gam?

Open rokapre opened this issue 2 years ago • 0 comments

Please specify whether your issue is about:

  • [ ] a possible bug
  • [xx ] a question about package functionality
  • [xx ] a suggested code or documentation change, improvement to the code, or feature request

Hi,

I was wondering is it possible at all to use margins with models from mgcv::gam() ? This is a common situation where I fit a penalized spline model and I would like to get the AME.

Below, I get the error "Error in J %*% vcov : non-conformable arguments"

Best,

Rohan

library(mgcv)
library(margins) 

x=rnorm(1000,0,0.1)
y = log(x+1) + rnorm(1000,0,0.2)
df = data.frame(x=x,y=y)
mod = gam(y~s(x),data=df)
margins(mod)

rokapre avatar Sep 28 '21 21:09 rokapre