R: multicollinearity issues using glib(), Bayesian Model Averaging (BMA-package) -
i experiencing difficulties estimating bma-model via glib(), due multicollinearity issues, though have specified columns use. please find details below.
the data i'll using estimation via bayesian model averaging:
cij <- c(357848,766940,610542,482940,527326,574398,146342,139950,227229,67948, 352118,884021,933894,1183289,445745,320996,527804,266172,425046, 290507,1001799,926219,1016654,750816,146923,495992,280405, 310608,1108250,776189,1562400,272482,352053,206286, 443160,693190,991983,769488,504851,470639, 396132,937085,847498,805037,705960, 440832,847631,1131398,1063269, 359480,1061648,1443370, 376686,986608, 344014) n <- length(cij); tt <- trunc(sqrt(2*n)) <- rep(1:tt,tt:1); #row numbers: year of origin j <- sequence(tt:1) #col numbers: year of development k <- i+j-1 #diagonal numbers: year of payment #since k=i+j-1, have leave out dummy in order avoid multicollinearity k <- ifelse(k == 2, 1, k)
i want evaluate effect of i , j both via levels , factors, of course not in same model. since can decide include i , j factors, levels, or not include them @ , k either include level, or exclude, there total of 18 (3x3x2) models. brings following data frame:
x <- data.frame(cij,i.factor=as.factor(i),j.factor=as.factor(j),k,i,j) x <- model.matrix(cij ~ -1 + i.factor + j.factor + k + + j,x) x <- as.data.frame(x[,-1])
next, via following declaration specify variables consider in each of 18 models. according me, no linear dependence exists in these specifications.
model.set <- rbind( c(rep(0,9),rep(0,9),0,0,0), c(rep(0,9),rep(0,9),0,1,0), c(rep(0,9),rep(0,9),0,0,1), c(rep(0,9),rep(0,9),1,0,0), c(rep(1,9),rep(0,9),0,0,0), c(rep(0,9),rep(1,9),0,0,0), c(rep(0,9),rep(0,9),0,1,1), c(rep(0,9),rep(0,9),1,1,0), c(rep(0,9),rep(1,9),0,1,0), c(rep(0,9),rep(0,9),1,0,1), c(rep(1,9),rep(0,9),0,0,1), c(rep(1,9),rep(0,9),1,0,0), c(rep(0,9),rep(1,9),1,0,0), c(rep(1,9),rep(1,9),0,0,0), c(rep(0,9),rep(0,9),1,1,1), c(rep(0,9),rep(1,9),1,1,0), c(rep(1,9),rep(0,9),1,0,1), c(rep(1,9),rep(1,9),1,0,0))
then call glib() function, telling select specified columns x according model.set.
library(bma) model.glib <- glib(x,cij,error="poisson", link="log",models=model.set)
which results in error
error in glim(x, y, n, error = error, link = link, scale = scale) : x matrix not full rank
the function first checks whether matrix f.c.r, before evaluates columns select x via model.set. how circumvent this, or there other way include 18 models in glib() function?
thank in advance.
Comments
Post a Comment