4

I am trying to do Program Evaluation for my data set which is "growth" (basically it is the gdp of each country).

I have already ruled out all of the countries that do not have a complete set of data for the time period 1980-2000 so I am sure that I do not have any missing data.

After importing the data into R, I followed the instructions in the paper: An R Package for the Panel Approach Method for Program Evaluation: pampe by Ainhoa Vega-Bayo

This is a screen shot of how my data looks like in RStudio.

> time.pretr<-c("1980", "1983")
> time.tr<-c("1984","1994")
> treated <-"SOUTHAFRICA"
> econ.integ<-pampe(time.pretr = time.pretr,time.tr = time.tr,treated = treated,data = growth)
Error in leaps.setup(x, y, wt = weights, nbest = nbest, nvmax = nvmax,  : 
 y and x different lengths

What could I do to resolve this error and what does it mean when it says "y and x different lengths"?

Please note, this is my first time using R/RStudio so I am not familiar with the terms. If anyone could offer some help, it would be greatly appreciated.

zx8754
  • 52,746
  • 12
  • 114
  • 209
Cyndi.uct
  • 61
  • 2
  • 4
  • 2
    It is hard to replicate the problem without [example data](http://stackoverflow.com/questions/5963269). Error is coming from `leaps.setup` which is called from `pampe`, have a look at pampe function what arguments are being passed to leaps. Also, maybe relevant post: http://stackoverflow.com/a/5176002/680068 – zx8754 Feb 23 '17 at 09:10

2 Answers2

2

My solution was the following:

x - has to be created using as.martix(your_data) and

y - has to be created as: your_data$target_column

1

It appears leaps is very particular of the data structures used. As Александр Ласкорунский wrote he had to use those particular structures. I tried some experimenting and it seems that the x entry HAS to be a matrix data structure. Not a data frame or a tibble but specifically a matrix. For the y argument the structure MUST be a vector. I'm sure the more versed individuals in this area would be able to expand on this.

EDIE: Seems not only a vector but it has to be an atomic vector.

D.C. the III
  • 340
  • 3
  • 14