Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upderivatives can't handle by variable smooths #47
Comments
|
Here's a reproducible example using set.seed(1)
dat <- gamSim(4, n = 400, verbose = FALSE)
m <- gam(y ~ fac + s(x2, by = fac), data = dat)
d <- derivatives(m)
draw(d) # clearly shows the problemand another one for testing m2 <- gam(y ~ x1 + s(x2) + fac + s(x0, by = fac), data = dat)and another one for testing, this time ordered factor dat <- transform(dat, ofac = ordered(fac))
m3 <- gam(y ~ x1 + s(x2) + ofac + s(x0) + s(x0, by = ofac), data = dat) |
|
An immediate issue is that |
|
This is now working for both ordered and ordinary factor by smooths for Thanks for the report. |
I really like the derivatives function, but I have been running into this issue.
The issue occurs whether I use ordered or unordered factors in the by-factor smooths. I have been mostly testing this with
gamm, but it seems to not work forgameither.For example:
modobj <- gamm(y ~ s(age,by = sex),random=list(ID=~1)df <- derivatives(modobj,'age)This returns the derivative for the first level of the by factor smooth, but returns all zeros for the derivative and standard error for the next level.
If I run this in the ordered factor case to test for interactions,
modobj <- gamm(y ~ s(age) +oSex + s(age,by = oSex),random=list(ID=~1)df <- derivatives(modobj,'age)It returns the derivative for the reference smooth (
s(age)), but all zeros for the derivative and standard error of the by factor smooth.