程序如下:
> curwd = setwd("D:/R/work")
> df <- read.csv('activedata.csv',header = TRUE)
> dataDF <- df[,2:4]
> names(dataDF) <- c("counts","timelength","totallength")
> head(dataDF)
counts timelength totallength
1 39 2 17
2 18 1 17
3 90 15 17
4 26 2 17
5 34 7 17
6 148 15 17
> attach(dataDF)
> x <- counts
> t <- timelength
> T <- totallength
> library(maxLik)
载入需要的程辑包:miscTools
Please cite the 'maxLik' package as:
Henningsen, Arne and Toomet, Ott (2011). maxLik: A package for maximum likelihood estimation in R. Computational Statistics 26(3), 443-458. DOI 10.1007/s00180-010-0217-1.
If you have questions, suggestions, or comments regarding the 'maxLik' package, please use a forum or 'tracker' at maxLik's R-Forge site:
https://r-forge.r-project.org/projects/maxlik/
> LL <- function(para,x,t,T)
+ {r <- para[1]
+ s <- para[2]
+ a <- para[3]
+ b <- para[4]
+
+ logL <- log(gamma(r+x))-log(gamma(r))+r*log(s)+log(gamma(a+b))+log(gamma(b+x))-log(gamma(para[4]))-log(gamma(a+b+x))
+ +log((s+q)^(-r-x)+(a/(b+x-1))*(s+t)^(-r-x))
+ return(logL)
+ }
> result <- maxLik(LL,grad = NULL,hess = NULL)
Error in checkFuncArgs(fn, argNames, "fn", "maxNR") :
argument 't' of the function specified in argument 'fn' of function 'maxNR' (partially) matches the argument names of function 'maxNR'. Please change the name of this argument
这是什么原因,是我的数据格式有问题吗


雷达卡





京公网安备 11010802022788号







