Google Summer of Code 2026 - Avanish Salunke

Five new methods for CompactLinearModel and two bug fixes

July 23, 2026 | 6 Minute Read

Last week the initial CompactLinearModel classdef landed with just its properties and constructor. This week the class actually became usable: coefCI, coefTest, predict, random, and feval were all added and checked against MATLAB. Along the way two real bugs turned up and got fixed - one where coefficients could come out in the wrong order compared to MATLAB, and one where feval didn't handle a categorical value passed in as plain text.

Project Status

Week 1 was project planning and setup.

Week 2 was the class shell: properties, access rules, the display method, and the subsref gatekeeper.

Week 3 was the constructor and fitlm: the math solver, all the diagnostics, the full 26-property object, and the front-end parser.

Week 4 was applying mentor feedback, refactoring the constructor, and adding predict and random.

Week 5 was feval, coefCI, coefTest, dwtest, and addTerms.

Week 6 was removeTerms, plotResiduals, plotDiagnostics, plotEffects, and a set of bug fixes.

Week 7 was the midterm evaluation, robust regression, plotAdjustedResponse, and plotAdded.

Week 8 was plot, plotInteraction, compact, and the initial CompactLinearModel structure.

This week was coefCI, coefTest, predict, random, and feval on CompactLinearModel, plus two bug fixes.


coefCI on CompactLinearModel - here

coefCI returns a confidence interval for every coefficient in the model. Each row of the output is one coefficient’s lower and upper bound, at whatever significance level you ask for (95% by default).

octave:8> cmdl = compact (mdl);
octave:9> ci = coefCI (cmdl)
ci =

  -0.1205   0.3529
   1.4702   3.5467
  -1.0269  -0.9308
ci = coefCI (cmdl, 0.01)   ## 99% intervals instead of the default 95%

A narrower confidence level gives a tighter interval, and a wider one gives a looser interval, since the method just scales the width of each bound based on the coefficient’s standard error.

coefTest on CompactLinearModel - here

coefTest checks whether one or more coefficients are equal to some value, usually zero. Called with no arguments it runs the overall model test - are all the coefficients except the intercept zero?

octave:22> [p, F, r] = coefTest (cmdl)
p = 9.4899e-28
F = 1.2831e+04
r = 2

You can also give it your own hypothesis as a contrast matrix, to test something more specific, like whether two coefficients are equal to each other:

octave:31> H = [0 1 -1];
octave:32> [p, F, r] = coefTest (cmdl, H)
p = 3.2021e-06
F = 45.992
r = 1

A small p-value means the data gives strong evidence against the hypothesis being tested.

predict on CompactLinearModel - here

predict computes the fitted response at new predictor values, with optional confidence or prediction intervals.

octave:33> Xnew = [0.5 0.25; 1.0 1.0];
octave:34> [ypred, yci] = predict (cmdl, Xnew)
ypred =

   1.1257
   1.6458

yci =

   0.8102   1.4412
   0.8582   2.4334

Options let you change the confidence level, ask for a simultaneous bound across all points instead of a pointwise one, and switch between a confidence interval on the mean response or a wider prediction interval for a single future observation.

[ypred, yci] = predict (cmdl, Xnew, 'Alpha', 0.01)
[ypred, yci] = predict (cmdl, Xnew, 'Simultaneous', true)
[ypred, yci] = predict (cmdl, Xnew, 'Prediction', 'observation')

random on CompactLinearModel - here

random simulates new response values. It computes the fitted response the same way predict does, and then adds a bit of random noise on top, matching the amount of noise estimated in the original fit.

octave:37> ysim = random (cmdl, Xnew)
ysim =

   1.1452
   1.9922
octave:38> ysim = random (cmdl, Xnew)
ysim =

   1.1999
   1.8687

Because the noise is random, calling random twice with the same input gives two different answers each time.

feval on CompactLinearModel - here

feval also returns fitted predictions, but instead of taking one matrix of predictor values, it takes each predictor as its own separate argument. This makes a fitted model usable anywhere a plain function is expected.

feval (cmdl, x1, x2)     ## one value per predictor
feval (cmdl, X)          ## a full matrix in one go, same as predict

Bug Fix: passing a category as plain text to feval - here

feval supports passing predictor values as separate arguments instead of one matrix. For a categorical predictor, one of those arguments can be the category name itself as plain text, like a year written as '70', rather than its numeric code.

This case wasn’t handled correctly. A short piece of text wasn’t treated as a single value the way a plain number is, so it got confused with mismatched-size numeric data and rejected. A single-character category would have been silently swapped for its character code instead of its real category, which is just as wrong even though nothing had caught it.

feval (cmdl, w, '70')             ## text category, resolved to its numeric code
feval (cmdl, w, categorical (70)) ## a categorical value works the same way
feval (cmdl, w, '99')             ## a category that doesn't exist gives NaN

The fix checks whether an argument is text or a category first, looks up which numeric code it corresponds to, and only then continues with the normal calculation.

Bug Fix: coefficients coming out in the wrong order - here

The order coefficients appear in a fitted model should follow the order of the columns in the input data table. Internally, this order was instead being sorted alphabetically by variable name, so a model with predictors named, say, Weight and Year could end up listing Year first even though Weight was the first column in the table.

Expected : (Intercept), Horsepower, Weight, Origin_France, ...
Got      : (Intercept), Horsepower, Origin_France, ..., Weight

The fix reorders the internal variable list, and the coefficients built from it, to follow the data table’s actual column order rather than an alphabetical sort.

Bug Fix: model display said “Coefficients:” instead of “Estimated Coefficients:” - here

The header printed above the coefficient table when displaying a fitted model said Coefficients:. It should say Estimated Coefficients:. A small text change fixes the display for both the full model and the compact model.


Development Branch

All the code is on this branch: gsoc-2026-linearmodel


Next Steps

  • plotEffects and plotInteraction on CompactLinearModel - main-effect and interaction-effect plots for a fitted model.
  • stepwiselm - automated model selection by forward and backward stepping.

Stay tuned for the next update!