[R-br] get.best.arima <- function (Error in solve.default(res$hessian * n.used) : Lapack routine dgesv: system is exactly singular)

carlos pombo sonderblohm c.sonderblohm em gmail.com
Segunda Outubro 15 13:27:19 BRT 2012


Caros amigos, estou a correr uma função para obter o *best fitting
model* baseado
no AIC. Esta função esta no livro de Introductory time series with R, de
Metcalfe and Cowperwait na pagina 144, dispoinivel no site:
http://tur-www1.massey.ac.nz/~pscowper/ts/scripts.R
a serie a modelar es

structure(c(-0.289220360456516, -0.412287982738894, -0.301861636262529,
-0.325463729174269, -0.95094391881209, -0.621873409193565,
-0.454370839103367,
-0.201717177298859, -0.0125484487133019, 0.375016273062132,
0.860628415115299,
0.573001978891618, 0.949171439258297, 0.884107931496505, 0.321528581746019,
0.197039928762376, -0.0511602427005631, -0.14797533453817,
0.0997648324025207,
-0.356603216398344, -0.486741440877118, -0.796433339558245,
-0.79771789875161,
-1.03991357760201, -0.272391281348931, -0.280840105493716,
-0.220566038983019,
-0.0929820260323471, -0.737941509253828, -0.257204432087439,
0.281594104947967, 0.295827677265899, 0.381173023222876, 0.410685495501985,
0.0935538548738126, 0.320870181634449, -0.176916211372864,
-0.434468255568435,
-0.177142353391016, -0.479723718529783, -1.18506069524595,
-0.845078218877218,
-0.466484365108014, -0.37831053186129, -0.568334035779147,
-0.756612458676532,
-0.612289956791276, -0.595067441206467, 0.227790700535618,
-0.328474103547926,
0.0382893789935963, -0.107472883393397, 0.104836312989006,
0.206908642082212,
0.566811114425555, 0.226484501566576, 0.268795384938631, 0.247658319827575,
0.728293948754544, 0.704287103883027, 0.66505780368502, 1.01752383083208,
1.34104381438303, 1.10724539596799, 0.850746327229352, 0.746239914170797,
0.665531282137069, 0.469573210434808, -0.0626525410819472,
-0.29470278010502,
-0.160850370184093, 0.511318161080906), .Tsp = c(1995, 2000.91666666667,
12), class = "ts")

a função es # Chapter 7, p144

get.best.arima <- function(x.ts, maxord = c(1,1,1,1,1,1))
{
  best.aic <- 1e8
  n <- length(x.ts)
  for (p in 0:maxord[1]) for(d in 0:maxord[2]) for(q in 0:maxord[3])
    for (P in 0:maxord[4]) for(D in 0:maxord[5]) for(Q in 0:maxord[6])
    {
       fit <- arima(x.ts, order = c(p,d,q),
                          seas = list(order = c(P,D,Q),
                          frequency(x.ts)), method = "CSS")
       fit.aic <- -2 * fit$loglik + (log(n) + 1) * length(fit$coef)
       if (fit.aic < best.aic)
       {
         best.aic <- fit.aic
         best.fit <- fit
         best.model <- c(p,d,q,P,D,Q)
       }
    }
  list(best.aic, best.fit, best.model)
}


O erro esta aqui:

> best.arima.SLCENT <- get.best.arima(SLCENT, maxord = c(2,2,2,2,2,2))
Error in solve.default(res$hessian * n.used) :
  Lapack routine dgesv: system is exactly singular

Muito obrigado
Carlos

P.D.: meu R es R version 2.13.1 (2011-07-08)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-pc-mingw32/x64 (64-bit)
-- 
Carlos A. Pombo Sonderblohm
PhD Student on Marine Science (Fisheries)
Faculdade de Ciências e Tecnología
Universidade do Algarve,
Campus de Gambelas
8005-139 Faro
Portugal
Tef. 289 800 905 ext. 7605
-------------- Próxima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://listas.inf.ufpr.br/pipermail/r-br/attachments/20121015/5b69a250/attachment.html>


Mais detalhes sobre a lista de discussão R-br