andyphilips / dynamac

Dynamic simulation and testing for single-equation ARDL models, available for both R and Stata
https://andyphilips.github.io/dynamac/
Apache License 2.0
7 stars 6 forks source link

'data' must be of a vector type, was 'NULL' #10

Closed crhammon closed 3 years ago

crhammon commented 3 years ago

Error (forgive any typos, I have no internet connection where I have R installed):

Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(X), :
    'data' must be of a vector type, was 'NULL'

I successfully used the ineq dataset, but am failing with my own data despite the fact that str(ineq) tells me my dataframe is identical in structure to ineq and I have 100% complete cases and no missing values or NAs.

My model that returns the error:

mod = dynardl(VarName ~ VAR1,
                         data = dataframename,
                         lags = list('VAR1' = 1),
                         diffs = c('VAR1'),
                         ec = TRUE,
                         simulate = FALSE
                         )

Model that works

mod = dynardl(concern ~ incshare10 + urate,
                         data = ineq,
                         lags = list('concern' = 1,'incshare10' = 1),
                         diffs = c('incshare10','urate'),
                         ec = TRUE,
                         simulate = FALSE
                         )

again, str(ineq) tells me my data is identical to ineq and I checked for missing values and I manually inspected the data and every value is real and valid.

I tried to reproduce the error on my other laptop, with everything being the same, and I could not get the same error.

Any clue about what might be happening?

Much obliged,

Charlie

sorenjordan commented 3 years ago

Charlie, Sorry for the inconvenience! This is a really confusing example, since everything looks in order. My off-the-cuff guess is that dataframename was written over a few times and lost between sessions, especially if it works on one machine and not the other. What comes up if you run some basic investigation on the dataframe (head(dataframename), etc.).

crhammon commented 3 years ago

I wish I could copy and paste for you!

head(dataframename) shows similar things for both ineq and dataframename: nothing remarkable.

I even did dataframename[is.na(dataframename)] = 0 just to be cautious, as this would fill any null values that I had somehow missed. But I get the exact same error! This is quite vexing.

I somehow got it to work though. I think the key issue is I was trying to use a previously defined string as my dependent variable, while the function was looking for that defined variable name as a column in the data! It gets confusing sometimes when you put column names into a function without quotes, that makes it so I can't define var1 = 'string1' and use var1 in a formula in a function.

Thanks for the response, all good now! I chalk this up to my having more experience with Python, where this sort of thing doesn't happen.