// globals

function preprocess () {
  

echo ('  require(eRm)\n');
}

function calculate () {
  
  mpoints      = getValue("mpoints");
  groups       = getValue("groups");
  group_vec    = getValue("group_vec");
  design       = getValue("design");
  design_mtx   = getValue("design_mtx");
  etastart     = getValue("etastart");
  etastart_vec = getValue("etastart_vec");
  stderr       = getValue("stderr");
  sumnull      = getValue("sumnull");

echo ('estimates.lpcm <<- LPCM(' + getValue("x"));
                  
                  if(design == "matrix") echo (", W="+design_mtx);
                  if(mpoints > 1) echo (", mpoints="+mpoints);
                  if(groups == "contrasts") echo (", groupvec="+group_vec);
                  if(stderr != "se") echo (", se=FALSE");
                  if(sumnull != "sum0") echo (", sum0=FALSE");
                  if(etastart == "startval") echo (", etaStart="+etastart_vec);
 echo (')\n');
}

function printout () {
echo ('rk.header ("LPCM  parameter estimation")\n');
echo ('rk.print (estimates.lpcm)\n');
}
