2016-08-24 167 views
0

我试图预测拟合gamlss模型的数据,并且有一个烦人的问题,我无法处理。r - data.frame(data,source = namelist)中的错误:参数意味着行数不同:3,4 - 在predict()中

Error in data.frame(data, source = namelist) : 
    arguments imply differing number of rows: 3, 4 

代码&数据

library('gamlss') 
asfr=c(0.0000000000,0.0001818271,0.0001818271,0.0228344684,0.0228344684) 
ages=c(12:16) 
data=data.frame(y=asfr,x=ages) 
model=gamlss(y~x,data=data,method=mixed(1,20)) 
test=data.frame(x=c(12,13,14)) 
predict(model,newdata=test, type = "response") 

我搜索了一些similiar问题,但reshape2答案没有工作。

此外,作为一个例子,我使用的代码在第89页up here

回答

0

我有同样的错误安装一个BEOI家庭,并试图预测它在gamlss。我不知道为什么,但在预测函数中添加我的初始模型数据源有助于解决此问题。希望能帮助到你!

predy <- predict(mod, what= "mu", newdata= data.frame(x= predx), type= "response", data= data) 
相关问题