title: Problems with within and random models in plm package
body: <p>I am working with plm package and I have problem with random and within models, which are giving errors which says "empty model". However, the model is not empty. In the source code for plm.fit, where the error originates it says something like (writing from the top of my head...)</p>
  
  <pre><code>X &lt;- model.matrix(formula,data, lhs=1,...)
  if (ncol(X) == 0) stop("empty model")
  </code></pre>
  
  <p>however if I try to replicate this behaviour with the commands I am inputing into the original function, it gives ncol(X) is 17 or something like that.</p>
  
  <p>My code is (data deleted...):</p>
  
  <pre><code>library(sampleSelection)
  library(foreign)
  library(censReg)
  library(plm)
  library(micEcon)
  library(ggplot2)
  
  data &lt;- read.dta('kpfull1.dta')
  summary(data)
  attach(data)
  
  data$profit_share &lt;- p91/tnsvp
  data$debt_assets &lt;- d91/naba
  data$naba3 &lt;- naba^3
  data$difprofit &lt;- p91-p90
  data$agri &lt;- (mind==1)*1
  data$hi &lt;- (mind==2)*1
  data$li &lt;- (mind==3)*1
  data$constr &lt;- (mind==4)*1
  data$trans &lt;- (mind==5)*1
  data$trade &lt;- (mind==6)*1
  data$rd &lt;- (mind==7)*1
  data$ser &lt;- (mind==8)*1
  data$fin &lt;- (mind==9)*1
  data$for1 &lt;- data[,7]
  detach(data)
  data1 &lt;- data
  panel &lt;- pdata.frame(data, c("num","rnd"))
  
  testovaci &lt;- plm(tb ~ profit_share  + debt_assets + naba + naba3 + for1 + dom + difprofit + agri + hi + li + constr + trans + trade + rd + ser + fin, data = panel, model = "within")
  summary(testovaci)
  
  model.matrix(tb ~ profit_share  + debt_assets + naba + naba3 + for1 + dom + difprofit + agri + hi + li + constr + trans + trade + rd + ser + fin, data)
  
  model.matrix(tb ~ profit_share  + debt_assets + naba + naba3 + for1 + dom + difprofit + agri + hi + li + constr + trans + trade + rd + ser + fin, panel)
  </code></pre>
  
  <p>Thanks,
  Tomáš Křehlík.</p>