0

i have a problem running this plm model:

my data are (example):

    country=c(1,1,1,2,2,2,3,3,3)
    year=c(1,2,3,1,2,3,1,2,3)
    a=c(1,4,6,3,5,8,4,5,7)
    b=c(8,5,7,2,7,4,9,7,1)
    matrix=cbind(country, year, a, b)
    matrix=plm.data(matrix)

I run following regression:

    reg=plm(a~year+b, data=matrix, index=NULL, model="within")
    summary(reg)

and get following warning message:[1]

    Warning messages:
    1: In if (is.na(le)) { :
      the condition has length > 1 and only the first element will be used
    2: In if (is.na(le)) " __no length(.)__ " else if (give.length) { :
      the condition has length > 1 and only the first element will be used
    3: In if (le > 0) paste0("[1:", paste(le), "]") else "(0)" :
      the condition has length > 1 and only the first element will be used

What is wrong?

landroni
  • 2,902
  • 1
  • 32
  • 39
  • That code throws an error in the line with `plm.data` with pkg:plm version 1.4-0. – IRTFM May 08 '14 at 22:17
  • @ user3237581: Have you found out more about this error? I would very much interested in this. – majom May 19 '14 at 09:53

2 Answers2

1

I had the same problem and found an answer (here)

This warning is given when a vector like this:

le<-c(4,2,6,5)

is used in a test like this:

if(is.na(le)) ...

R only looks at the first value in the vector for the test, but warns you that there were other values that were not tested. If the test was:

if(is.na(le[1]))

It doesn't matter if "le" has only one value or more than one and you don't get the warning. It usually doesn't mess anything up.

SJDS
  • 1,239
  • 1
  • 16
  • 31
1

This is because str checks the length of its object, and plm uses extended formulas from the Formula package. Now, Formula:::length.Formula returns a vector rather than a number, which causes the warning, as explained by simon_icl. While you may not call str yourself, perhaps your IDE, say RStudio, may use it to show the object structure of objects in the workspace.

Stefan
  • 1,835
  • 13
  • 20