1

I would like to make a gls model using these vectors:

v1 <- c( 3.27985464, -0.40586830, -0.40586830, -0.09872472, -0.09872472, -0.40586830, -0.40586830,  0.82270601, -0.40586830, -0.40586830, -0.25229651, -0.40586830, -0.40586830, -0.40586830)

year <- c(2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014)

To proceed I did:

gls(v1 ~ year, correlation=(corAR1(value = acf(v1, lag.max = 1)$acf[2])))

And I got the following error:

Error in gls(v1 ~ year, correlation = corAR1(value = acf(v1,  : 
  singular convergence (7)

Do you know where is the issue and how I could solve it?

Roxanne
  • 11
  • 3
  • 2
    I think length of `year` and `v1` is different. I ran your commands after removing 1 element from `year` and worked fine. – Sagar Aug 22 '17 at 13:45
  • Maybe related/duplicate posts [here](https://stackoverflow.com/questions/22229352/nls-convergence-failure-singular-convergence-7) and [here](https://stackoverflow.com/questions/7923387/error-with-nlme). – zx8754 Aug 22 '17 at 13:48
  • Ah yes sorry, I forgot a term in v1. I just corrected it, now you should have the error... – Roxanne Aug 22 '17 at 14:29
  • Ok, this code is actually working, meaning that somehow the issue is in the structure of my vector v1 that is in my script 'loss_scaled <- tab_loss[tab_loss$id == i,][,4]' . I don't know why it does not work for this vector when it works for all others in the loop but I will find it out. Thank you anyway ! – Roxanne Aug 22 '17 at 14:54

1 Answers1

0

The vector v1 has the value -0.40586830 repeated many times in a row, causing perfect fit in the AR1.