debugging - R:Implementing variable selection in panel data model -


i doing panel data analysis 17 variables in r using package "plm".
have eliminate these variables while retaining significant of them. looking @ adjusted r-square set of variables best explain dependent variable. since have 17 variables, repeating , observing again and, again has become cumbersome. following code:

attach(pdf)  pdata <-plm.data(pdf,index=c("country","day"))  y <- cbind(dep_var)  var_list <- pdf[c("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q")] between_models= list()  r_sqrt=c() for(i in 1:17){ x<-cbind(var_list[,1:i]) between_models[i]=plm(y~ x, data=pdata, model= "between") r_sqrt[i]=coef(between_models[i])["adj. r-squared"] } print(paste("least  adj. r-squared is",which.max(r_sqrt)) print(between_models[[which.max(r_sqrt)]]) # print least  adj. r-squared model 

what trying above code increase number of variables in y , estimate between model again , again till y has maximum number of variables. , @ list of adjusted r-square values , pick summary model highest adjusted r-square. when run above code gives following error:

error in model.frame.default(terms(formula, lhs = lhs, rhs = rhs, data = data,  : invalid type (list) variable 'x' 

in above code loop, seems there problem in type of variable x. please suggest how fix loop runs , give least adjusted r-square model result.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -