Reputation: 13
I'm trying to predict data on fitted gamlss model, and have an annoying issue,that i can't deal with.
Error in data.frame(data, source = namelist) :
arguments imply differing number of rows: 3, 4
Code&data
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")
I searched for some similiar issues, but answers with reshape2 didn't work.
Also, as an example i used code on p.89 up here
Upvotes: 0
Views: 970
Reputation: 39
I had the same problem, and while adding the initial model data in the predict function sometimes helped, more often than not it didn't.
So I contacted Mikis Stasinopoulos who as usual was very helpful. It turns out that the problem is that the dataset I was using was called "data" and while that's fine for estimation, it's not for prediction. Renaming the dataset "mydata" throughout solved the problem.
Upvotes: 2
Reputation: 11
I had the same error fitting a BEOI family and trying to predict it in gamlss. I do not know why, but adding my initial model data source in the predict function helped resolve it. Hope it helps!
predy <- predict(mod, what= "mu", newdata= data.frame(x= predx), type= "response", data= data)
Upvotes: 1