lotze / COMPoissonReg

COMPoissonReg R package
GNU General Public License v2.0
9 stars 4 forks source link

Error in UseMethod("nu") #7

Closed sravanthikolla closed 4 years ago

sravanthikolla commented 4 years ago

Hello, I was trying to fit under dispersed count data using "nu" function but got an error " no applicable method for 'nu' applied to an object of class "c('glm', 'lm')"". please suggest me how to solve the issue. Thank you

andrewraim commented 4 years ago

Hello,

It sounds like you may be calling the nu function on an object which was not output from the glm.cmp function. Can you provide a minimal-but-complete example that I can use to replicate the error? Also, are you using the latest version of the package from CRAN, or something else?

Here is an example where the nu function works as intended. I used COMPoissonReg version 0.7.0.

R> library(COMPoissonReg)
R> data(freight)
R> cmp.out = glm.cmp(broken ~ transfers, data=freight)
R> print(cmp.out)
CMP coefficients
              Estimate     SE z.value  p.value
X:(Intercept)  13.8330 6.2434  2.2156  0.02672
X:transfers     1.4847 0.6895  2.1534  0.03129
S:(Intercept)   1.7553 0.4493  3.9066 9.36e-05
--
Transformed intercept-only parameters
   Estimate     SE
nu   5.7853 2.5994
--
Chi-squared test for equidispersion
X^2 = 9.1048, df = 1, p-value = 2.5494e-03
--
Elapsed Sec: 0.03   Sample size: 10   SEs via Hessian
LogLik: -18.6449   AIC: 43.2898   BIC: 44.1975   
Optimization Method: L-BFGS-B   Converged status: 0
Message: CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH
R> coef(cmp.out)
X:(Intercept)   X:transfers S:(Intercept) 
    13.833003      1.484698      1.755315 
R> nu(cmp.out)
 [1] 5.78527 5.78527 5.78527 5.78527 5.78527 5.78527 5.78527 5.78527 5.78527 5.78527