Reputation: 121
After loading mgcv and running the below model - it returns the error below.. This code has worked in previous times (i.e. yesterday). Any help with this would be much appreciated.
> aa1<-gam(Bin~s(Mud,bs="ps",k=8),family=binomial, gamma=1,data=Abaren)
Error in s(Mud, bs = "ps", k = 8) : unused argument(s) (bs = "ps", k = 8)
--
I'm now getting the error below.. This all seems rather strange given the fact all of this code was running perfectly just two days ago..
## UQ Abundance only data (i.e. positive values only)
aa2<-gam(UQdata~s(MudUQ,bs="ps", k=15) ,family=Gamma(link=log),data=Antho)
xmin <- ceiling(min(Antho$MudUQ[Antho$Bin==1]))
xmax <- floor(max(Antho$MudUQ[Antho$Bin==1]))
Mudnew <- seq(from=xmin, to=xmax, by=0.1)
**Error in if (del == 0 && to == 0) return(to) :
missing value where TRUE/FALSE needed**
pred.dat <- data.frame(Mudnew)
names(pred.dat) <- "MudUQ"
pred.aa2 <- data.frame(predict.gam(aa2, pred.dat, se.fit=TRUE, type="response"))
pred.aa2.comb <- data.frame(pred.dat, pred.aa2)
names(pred.aa2.comb)
plot(fit ~ MudUQ, data=pred.aa2.comb, type="l", lwd=2, col=1,
lab="Density per 0.0132 m2", xlab="Mud content (%)")
Upvotes: 1
Views: 2074
Reputation: 174778
Are you using the wrong package? Both the mgcv and gam packages have function s()
, but only the former's takes a bs
and a k
argument to influence the basis functions.
For example, I can reproduce the error using gam::gam()
:
> require("gam")
> data(kyphosis)
> gam(Kyphosis ~ s(Age, k = 4, bs = "ps") + Number, family = binomial,
+ data=kyphosis, trace = TRUE)
Error in s(Age, k = 4, bs = "ps") : unused arguments (k = 4, bs = "ps")
> gam(Kyphosis ~ s(Age) + Number, family = binomial, data=kyphosis, trace = TRUE)
GAM s.wam loop 1: deviance = 66.42095
GAM s.wam loop 2: deviance = 63.77252
GAM s.wam loop 3: deviance = 63.25199
GAM s.wam loop 4: deviance = 63.13399
GAM s.wam loop 5: deviance = 63.11016
GAM s.wam loop 6: deviance = 63.10748
GAM s.wam loop 7: deviance = 63.10727
GAM s.wam loop 8: deviance = 63.10725
GAM s.wam loop 9: deviance = 63.10725
Call:
gam(formula = Kyphosis ~ s(Age) + Number, family = binomial,
data = kyphosis, trace = TRUE)
Degrees of Freedom: 80 total; 75.00002 Residual
Residual Deviance: 63.10725
but not with the mgcv package and mgcv::gam()
:
> require(mgcv)
> require("mgcv")
> set.seed(2) ## simulate some data...
> dat <- gamSim(1,n=400,dist="normal",scale=2)
Gu & Wahba 4 term additive model
> b <- gam(y ~ s(x0, k = 5, bs = "ps") + s(x1) + s(x2) + s(x3), data=dat)
Loading required package: splines
Upvotes: 3