New Probability Model fitting using R Code

50 Views Asked by At

I have developed new probability model using generalized technique of mixturing. Now i want it's fitting on discrete data set. But i am getting error that

Error in seq.default(0, x) : 'to' must be of length 1 I don't understand, how to handle this. R code is below:

# rm(list=ls(all=TRUE))

obs=rep(seq(0,6),c(260,87,32,4,1,0,0))

NBWED<-function(x,r,alpha,beta){
j=seq(0,x)
C=function(n,x){
factorial(n)/(factorial(n-x)*factorial(x))
}
C(x+r-1,x)*sum(C(x,j)*(-1)^j*(alpha^2/(alpha+beta))*((r+j+alpha)+beta)/(r+j+alpha)^2)
}

library(MASS)
fit09=fitdistr(x = obs,densfun = NBWED,start = list(r=1,alpha=0.5,beta=9.4),lower = list(a = 0.1,0.001,0.001),upper=c(Inf,Inf,Inf))  
fit09
1

There are 1 best solutions below

0
eonurk On

seq(0,n) creates a vector from 0 to n. Probably, your x is a vector or something similar, therefore it throws an error.

Just try: seq(0,5) and see the result. It would help.