MATLAB: Is it possible to fit (generalized) linear mixed-effect models using “single” datatype

Statistics and Machine Learning Toolbox

I am trying to fit (generalized) linear mixed-effects models but with "single" datatype
the functions "fitlme" and "fitglme" generates error (a sample reproduction step is given below).
Is there any workaroud?
>> load flu
>> flu2 = stack(flu,2:10,'NewDataVarName','FluRate', 'IndVarName','Region');
>> flu2.Date = nominal(flu2.Date);
>> flu2.FluRate = single(flu2.FluRate);
>> flu2(1:6, 🙂
ans = 
    Date         WtdILI    Region       FluRate
    10/9/2005    1.182     NE            0.97  
    10/9/2005    1.182     MidAtl       1.025  
    10/9/2005    1.182     ENCentral    1.232  
    10/9/2005    1.182     WNCentral    1.286  
    10/9/2005    1.182     SAtl         1.082  
    10/9/2005    1.182     ESCentral    1.457  
>> lme = fitlme(flu2,'FluRate ~ 1 + WtdILI + (1|Date)')
Error using  * 
MTIMES is not supported for one sparse input and one single input.
Error in classreg.regr.lmeutils.StandardLinearMixedModel/refit (line 1475)
            slme.Zty = Z'*y;
Error in classreg.regr.lmeutils.StandardLinearMixedModel (line 1448)
                slme = refit(slme);
Error in LinearMixedModel/fitStandardLMEModel (line 1240)
        slme =
        classreg.regr.lmeutils.StandardLinearMixedModel(Xw,yw,Zsw,Psi,model.FitMethod,…
Error in LinearMixedModel/fitter (line 822)
        model.slme = fitStandardLMEModel(model);
Error in classreg.regr.FitObject/doFit (line 94)
            model = fitter(model);
Error in LinearMixedModel.fit (line 2395)
        model = doFit(model);
Error in fitlme (line 224)
    lme = LinearMixedModel.fit(ds,formula,varargin{:}); 
>>
>> lme = fitglme(flu2,'FluRate ~ 1 + WtdILI + (1|Date)')
Error using  * 
MTIMES is not supported for one sparse input and one single input.
Error in classreg.regr.lmeutils.StandardLinearMixedModel/refit (line 1475)
            slme.Zty = Z'*y;
Error in classreg.regr.lmeutils.StandardGeneralizedLinearMixedModel/fitUsingPL (line
1667)
                    slme = refit(slme);
Error in classreg.regr.lmeutils.StandardGeneralizedLinearMixedModel/refit (line 4315)
                    [sglme,cause] = fitUsingPL(sglme,numIter,kappa);
Error in classreg.regr.lmeutils.StandardGeneralizedLinearMixedModel (line 4288)
                sglme = refit(sglme);
Error in GeneralizedLinearMixedModel/fitStandardLMEModel (line 1317)
        slme =
        classreg.regr.lmeutils.StandardGeneralizedLinearMixedModel(X,model.y,Zs,Psi,model.FitMethod,dofit,dostats,args{:});
        Error in GeneralizedLinearMixedModel/fitter (line 891)
        model.slme = fitStandardLMEModel(model);
Error in classreg.regr.FitObject/doFit (line 94)
            model = fitter(model);
Error in GeneralizedLinearMixedModel.fit (line 2411)
        model = doFit(model);
Error in fitglme (line 389)
    glme = GeneralizedLinearMixedModel.fit(T,formula,varargin{:}); 
>> 

Best Answer

The current MATLAB release (R2016b) doesn't support "sparse*single" multiplication.
As a workaround, consider converting the input to "double".
Â