Are there known compatibility issues with R package mgcv? Are there general rules for compatibility?

旧街凉风 提交于 2020-01-03 13:04:12

问题


I use R version 2.15.1 (2012-06-22) and mgcv version 1.7-22

I load the following set of packages in R:


library(sqldf)
library(timeDate)
library(forecast)
library(xts)
library(tseries)
library(MASS)
library(mgcv)

It happens that I can not run a simple model (I omit the code). Even the sample code taken from the help pages:


dat = gamSim(1,n=400,dist="normal",scale=2)
b = gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat)

gives an error:


Error in qr.qty(qrc, sm$S[[l]]) : 
  NA/NaN/Inf in foreign function call (arg 5)
In addition: Warning message:
In smoothCon(split$smooth.spec[[i]], data, knots, absorb.cons, scale.penalty = scale.penalty,  :
  number of items to replace is not a multiple of replacement length

Note that everything works fine, if I just load the package mgcv and then use the sample code right away. It also works if I just load all the packages and run the sample code. It just does not work if I

  1. load all packages
  2. do some file reading, sqldf statements, ts operations and some models from package forecast.
  3. if I then apply GAM, it does not work anymore.

Apparently the variable definitions in the general environment mess up the functioning of the package.

Are there any known issues? Are there general rules that I have to obey if I load various packages? Can I write code that "disturbed" the package mgcv?


回答1:


@ Richard there are 2 GAM related packages: gam and mgcv. Loading both libraries at the same time usually causes a conflict.




回答2:


Loading mgcv as the first package solved my problem ... strange but true.



来源:https://stackoverflow.com/questions/14900248/are-there-known-compatibility-issues-with-r-package-mgcv-are-there-general-rule

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!