|
楼主 |
发表于 2015-4-10 12:55:37
|
显示全部楼层
自己回复下自己,这里的gamAR函数是一个自定义函数,找到了别人定义的程序,可是不懂,哪位大神帮忙解读一下,多谢啦
gamAR <- function (formula, data, p.ar=1, starts = starts, w = rep(1,NN),family = "poisson", cc = 0.5,de = 0.01,control=list(...),...)
{
if(family!="poisson")
stop("sorry, only poisson family is currently implemented")
family=poisson()
control <- do.call("glm.control", control)
times <- control$maxit
epsilon <- control$epsilon
if (missing(data))
data <- environment(formula)
mf <- match.call(expand.dots = FALSE)
m <- match(c("formula", "data"), names(mf), 0L)
mf <- mf[c(1L, m)]
mf$drop.unused.levels <- TRUE
mf[[1L]] <- as.name("model.frame")
mf <- eval(mf, parent.frame())
term.labels <- attr(attributes(mf)$terms,"term.labels")
mt <- attr(mf, "terms")
y <- model.response(mf, "any")
X <- model.matrix(mt, mf, contrasts)
xnames <- colnames(X)
ynames <- names(y)
b <-ncol(X)-1
p <- p.ar
NN <- NROW(y)
pp <-rep(0,p)
r<-matrix(0,times+1,1+b+p)
r[1,]<-c(starts,pp)
|
|