te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>How does Statsmodels ARIMA compute the first few fitted values? - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How does Statsmodels ARIMA compute the first few fitted values? - Stack Overflow

programmeradmin4浏览0评论

Suppose I have an ARIMA(p,d,q), d>0 that I estimate using statsmodels. (See ARIMA class here.) For in-sample forecasts for t >= d, I get exactly what I expect, namely the Y(t) uses exactly the observed values of Y(t-1), Y(t-2), ... as well as the estimated innovations (computed from innovations algorithm on differences series). (I will index the series starting at zero.)

For example, when d = 3, I get exactly

`Y_fitted(3) = 3 * Y(2) - 3 * Y(1) + Y(0) + estimated innovations(3)`

This exactly reproduces the statsmodels fit.fittedvalues values for any t >= d.

I am confused about the predictions for t < d though. It seems like (from simulating a bunch of ARIMA process, estimating, and regressing fitted values on lagged observations) that

  • Y_fitted(0) = 0 (which makes sense!)
  • Y_fitted(1) = (d+1)/2 * Y(0) (not sure where that comes from!)
  • Y_fitted(2) =
    • 2.5 * Y(1) - 1.667 * Y(0) when d=3
    • 3.0 * Y(1) - 2.500 * Y(0) when d=4
    • 3.5 * Y(1) - 3.500 * Y(0) when d=5
    • ...
  • Y_fitted(3) =
    • 3.5 * Y(2) - 4.2 * Y(1) + 1.75 * Y(0) when d=4
    • ...

For the life of me, despite googling and trying to reverse engineer a heuristic, I cannot figure out where these coefficients come from. I don't think they correspond to the best linear predictors given observed values to time-t, (but I am not sure about that either). Trying to step through the statsmodels code is too complicated. (The documentation for statsmodels does say the the initial residuals are funky, but doesn't say how they are actually computed. They aren't just padding zeros, they are doing something.)

Does anyone have any idea? Any guidance would be appreciated. I am happy to add code if people think that would be helpful but I think the question is more conceptual about the code.

发布评论

评论列表(0)

  1. 暂无评论