Index: /stable/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/HeuristicLab.Algorithms.DataAnalysis.Views-3.4.csproj
===================================================================
--- /stable/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/HeuristicLab.Algorithms.DataAnalysis.Views-3.4.csproj	(revision 17073)
+++ /stable/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/HeuristicLab.Algorithms.DataAnalysis.Views-3.4.csproj	(revision 17074)
@@ -142,4 +142,10 @@
     <Compile Include="OneFactorClassificationModelView.Designer.cs">
       <DependentUpon>OneFactorClassificationModelView.cs</DependentUpon>
+    </Compile>
+    <Compile Include="LinearRegressionModelView.cs">
+      <SubType>UserControl</SubType>
+    </Compile>
+    <Compile Include="LinearRegressionModelView.Designer.cs">
+      <DependentUpon>LinearRegressionModelView.cs</DependentUpon>
     </Compile>
     <Compile Include="RandomForestModelView.cs">
Index: /stable/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/LinearRegressionModelView.Designer.cs
===================================================================
--- /stable/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/LinearRegressionModelView.Designer.cs	(revision 17074)
+++ /stable/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/LinearRegressionModelView.Designer.cs	(revision 17074)
@@ -0,0 +1,153 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+namespace HeuristicLab.Algorithms.DataAnalysis.Views {
+  partial class LinearRegressionModelView {
+    /// <summary> 
+    /// Required designer variable.
+    /// </summary>
+    private System.ComponentModel.IContainer components = null;
+
+    /// <summary> 
+    /// Clean up any resources being used.
+    /// </summary>
+    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+    protected override void Dispose(bool disposing) {
+      if (disposing && (components != null)) {
+        components.Dispose();
+      }
+      base.Dispose(disposing);
+    }
+
+    #region Component Designer generated code
+
+    /// <summary> 
+    /// Required method for Designer support - do not modify 
+    /// the contents of this method with the code editor.
+    /// </summary>
+    private void InitializeComponent() {
+      this.parametersView = new HeuristicLab.Data.Views.StringConvertibleArrayView();
+      this.covarianceMatrixView = new HeuristicLab.Data.Views.StringConvertibleMatrixView();
+      this.parameterVectorLabel = new System.Windows.Forms.Label();
+      this.splitContainer = new System.Windows.Forms.SplitContainer();
+      this.covMatLabel = new System.Windows.Forms.Label();
+      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
+      this.splitContainer.Panel1.SuspendLayout();
+      this.splitContainer.Panel2.SuspendLayout();
+      this.splitContainer.SuspendLayout();
+      this.SuspendLayout();
+      // 
+      // parametersView
+      // 
+      this.parametersView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+            | System.Windows.Forms.AnchorStyles.Left)
+            | System.Windows.Forms.AnchorStyles.Right)));
+      this.parametersView.Caption = "StringConvertibleArray View";
+      this.parametersView.Content = null;
+      this.parametersView.Location = new System.Drawing.Point(6, 19);
+      this.parametersView.Name = "parametersView";
+      this.parametersView.ReadOnly = true;
+      this.parametersView.Size = new System.Drawing.Size(136, 267);
+      this.parametersView.TabIndex = 0;
+      // 
+      // covarianceMatrixView
+      // 
+      this.covarianceMatrixView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+            | System.Windows.Forms.AnchorStyles.Left)
+            | System.Windows.Forms.AnchorStyles.Right)));
+      this.covarianceMatrixView.Caption = "StringConvertibleMatrix View";
+      this.covarianceMatrixView.Content = null;
+      this.covarianceMatrixView.Location = new System.Drawing.Point(3, 19);
+      this.covarianceMatrixView.Name = "covarianceMatrixView";
+      this.covarianceMatrixView.ReadOnly = true;
+      this.covarianceMatrixView.ShowRowsAndColumnsTextBox = true;
+      this.covarianceMatrixView.ShowStatisticalInformation = true;
+      this.covarianceMatrixView.Size = new System.Drawing.Size(194, 267);
+      this.covarianceMatrixView.TabIndex = 1;
+      // 
+      // parameterVectorLabel
+      // 
+      this.parameterVectorLabel.AutoSize = true;
+      this.parameterVectorLabel.Location = new System.Drawing.Point(3, 0);
+      this.parameterVectorLabel.Margin = new System.Windows.Forms.Padding(3);
+      this.parameterVectorLabel.Name = "parameterVectorLabel";
+      this.parameterVectorLabel.Size = new System.Drawing.Size(63, 13);
+      this.parameterVectorLabel.TabIndex = 2;
+      this.parameterVectorLabel.Text = "Parameters:";
+      // 
+      // splitContainer
+      // 
+      this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
+      this.splitContainer.Location = new System.Drawing.Point(0, 0);
+      this.splitContainer.Name = "splitContainer1";
+      // 
+      // splitContainer.Panel1
+      // 
+      this.splitContainer.Panel1.Controls.Add(this.parametersView);
+      this.splitContainer.Panel1.Controls.Add(this.parameterVectorLabel);
+      // 
+      // splitContainer.Panel2
+      // 
+      this.splitContainer.Panel2.Controls.Add(this.covMatLabel);
+      this.splitContainer.Panel2.Controls.Add(this.covarianceMatrixView);
+      this.splitContainer.Size = new System.Drawing.Size(349, 289);
+      this.splitContainer.SplitterDistance = 145;
+      this.splitContainer.TabIndex = 4;
+      // 
+      // covMatLabel
+      // 
+      this.covMatLabel.AutoSize = true;
+      this.covMatLabel.Location = new System.Drawing.Point(3, 0);
+      this.covMatLabel.Margin = new System.Windows.Forms.Padding(3);
+      this.covMatLabel.Name = "covMatLabel";
+      this.covMatLabel.Size = new System.Drawing.Size(94, 13);
+      this.covMatLabel.TabIndex = 3;
+      this.covMatLabel.Text = "Covariance matrix:";
+      // 
+      // LinearRegressionModelView
+      // 
+      this.AllowDrop = true;
+      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
+      this.Controls.Add(this.splitContainer);
+      this.Name = "LinearRegressionModelView";
+      this.Size = new System.Drawing.Size(349, 289);
+      this.splitContainer.Panel1.ResumeLayout(false);
+      this.splitContainer.Panel1.PerformLayout();
+      this.splitContainer.Panel2.ResumeLayout(false);
+      this.splitContainer.Panel2.PerformLayout();
+      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
+      this.splitContainer.ResumeLayout(false);
+      this.ResumeLayout(false);
+
+    }
+
+
+
+
+    #endregion
+
+    private Data.Views.StringConvertibleArrayView parametersView;
+    private Data.Views.StringConvertibleMatrixView covarianceMatrixView;
+    private System.Windows.Forms.Label parameterVectorLabel;
+    private System.Windows.Forms.SplitContainer splitContainer;
+    private System.Windows.Forms.Label covMatLabel;
+  }
+}
Index: /stable/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/LinearRegressionModelView.cs
===================================================================
--- /stable/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/LinearRegressionModelView.cs	(revision 17074)
+++ /stable/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/LinearRegressionModelView.cs	(revision 17074)
@@ -0,0 +1,76 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion            
+
+using System.Linq;
+using HeuristicLab.Analysis;
+using HeuristicLab.Common;
+using HeuristicLab.Core.Views;
+using HeuristicLab.Data;
+using HeuristicLab.MainForm;
+using HeuristicLab.Problems.DataAnalysis;
+using HeuristicLab.Problems.DataAnalysis.Symbolic;
+using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
+
+namespace HeuristicLab.Algorithms.DataAnalysis.Views {
+  [View("Linear regression model")]
+  [Content(typeof(LinearRegressionModel), true)]
+  public partial class LinearRegressionModelView : ItemView {
+
+    public new LinearRegressionModel Content {
+      get { return (LinearRegressionModel)base.Content; }
+      set { base.Content = value; }
+    }
+
+    protected override void SetEnabledStateOfControls() {
+      base.SetEnabledStateOfControls();
+      parametersView.Enabled = Content != null;
+      covarianceMatrixView.Enabled = Content != null;
+    }
+
+    public LinearRegressionModelView()
+      : base() {
+      InitializeComponent();
+    }
+
+    protected override void OnContentChanged() {
+      base.OnContentChanged();
+      if (Content == null) {
+        parametersView.Content = null;
+        covarianceMatrixView.Content = null;
+      } else {
+        // format numbers to make them easier to read
+        var w = new StringArray(Content.W.Select(x => $"{x:e4}").ToArray());
+        w.ElementNames = Content.ParameterNames;
+        parametersView.Content = w;
+
+        // format all numbers in matrix
+        var cStr = new string[Content.C.GetLength(0), Content.C.GetLength(1)];
+        for (int i = 0; i < Content.C.GetLength(0); i++)
+          for (int j = 0; j < Content.C.GetLength(0); j++)
+            cStr[i, j] = $"{Content.C[i, j]:e4}";
+        var c = new StringMatrix(cStr);
+        c.RowNames = Content.ParameterNames;
+        c.ColumnNames = Content.ParameterNames;
+        covarianceMatrixView.Content = c;
+      }
+    }
+  }
+}
Index: /stable/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj
===================================================================
--- /stable/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj	(revision 17073)
+++ /stable/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj	(revision 17074)
@@ -263,4 +263,5 @@
     <Compile Include="Linear\MultinomialLogitClassification.cs" />
     <Compile Include="Linear\MultinomialLogitClassificationSolution.cs" />
+    <Compile Include="Linear\LinearRegressionModel.cs" />
     <Compile Include="Linear\MultinomialLogitModel.cs" />
     <Compile Include="Linear\Scaling.cs" />
Index: /stable/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/LinearRegression.cs
===================================================================
--- /stable/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/LinearRegression.cs	(revision 17073)
+++ /stable/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/LinearRegression.cs	(revision 17074)
@@ -41,5 +41,6 @@
   [StorableClass]
   public sealed class LinearRegression : FixedDataAnalysisAlgorithm<IRegressionProblem> {
-    private const string LinearRegressionModelResultName = "Linear regression solution";
+    private const string SolutionResultName = "Linear regression solution";
+    private const string ConfidenceSolutionResultName = "Solution with prediction intervals";
 
     [StorableConstructor]
@@ -62,24 +63,24 @@
     protected override void Run(CancellationToken cancellationToken) {
       double rmsError, cvRmsError;
-      var solution = CreateLinearRegressionSolution(Problem.ProblemData, out rmsError, out cvRmsError);
-      Results.Add(new Result(LinearRegressionModelResultName, "The linear regression solution.", solution));
+      // produce both solutions, to allow symbolic manipulation of LR solutions as well
+      // as the calculation of prediction intervals.
+      // There is no clean way to implement the new model class for LR as a symbolic model.
+      var solution = CreateSolution(Problem.ProblemData, out rmsError, out cvRmsError);
+#pragma warning disable 168, 3021
+      var symbolicSolution = CreateLinearRegressionSolution(Problem.ProblemData, out rmsError, out cvRmsError);
+#pragma warning restore 168, 3021
+      Results.Add(new Result(SolutionResultName, "The linear regression solution.", symbolicSolution));
+      Results.Add(new Result(ConfidenceSolutionResultName, "Linear regression solution with parameter covariance matrix " +
+                                                           "and calculation of prediction intervals", solution));
       Results.Add(new Result("Root mean square error", "The root of the mean of squared errors of the linear regression solution on the training set.", new DoubleValue(rmsError)));
       Results.Add(new Result("Estimated root mean square error (cross-validation)", "The estimated root of the mean of squared errors of the linear regression solution via cross validation.", new DoubleValue(cvRmsError)));
     }
 
+    [Obsolete("Use CreateSolution() instead")]
     public static ISymbolicRegressionSolution CreateLinearRegressionSolution(IRegressionProblemData problemData, out double rmsError, out double cvRmsError) {
-      var dataset = problemData.Dataset;
-      string targetVariable = problemData.TargetVariable;
-      IEnumerable<string> allowedInputVariables = problemData.AllowedInputVariables;
-      IEnumerable<int> rows = problemData.TrainingIndices;
-      var doubleVariables = allowedInputVariables.Where(dataset.VariableHasType<double>);
-      var factorVariableNames = allowedInputVariables.Where(dataset.VariableHasType<string>);
-      var factorVariables = dataset.GetFactorVariableValues(factorVariableNames, rows);
-      double[,] binaryMatrix = dataset.ToArray(factorVariables, rows);
-      double[,] doubleVarMatrix = dataset.ToArray(doubleVariables.Concat(new string[] { targetVariable }), rows);
-      var inputMatrix = binaryMatrix.HorzCat(doubleVarMatrix);
-
-      if (inputMatrix.ContainsNanOrInfinity())
-        throw new NotSupportedException("Linear regression does not support NaN or infinity values in the input dataset.");
+      IEnumerable<string> doubleVariables;
+      IEnumerable<KeyValuePair<string, IEnumerable<string>>> factorVariables;
+      double[,] inputMatrix;
+      PrepareData(problemData, out inputMatrix, out doubleVariables, out factorVariables);
 
       alglib.linearmodel lm = new alglib.linearmodel();
@@ -87,5 +88,4 @@
       int nRows = inputMatrix.GetLength(0);
       int nFeatures = inputMatrix.GetLength(1) - 1;
-      double[] coefficients = new double[nFeatures + 1]; // last coefficient is for the constant
 
       int retVal = 1;
@@ -95,7 +95,8 @@
       cvRmsError = ar.cvrmserror;
 
+      double[] coefficients = new double[nFeatures + 1]; // last coefficient is for the constant
       alglib.lrunpack(lm, out coefficients, out nFeatures);
 
-      int nFactorCoeff = binaryMatrix.GetLength(1);
+      int nFactorCoeff = factorVariables.Sum(kvp => kvp.Value.Count());
       int nVarCoeff = doubleVariables.Count();
       var tree = LinearModelToTreeConverter.CreateTree(factorVariables, coefficients.Take(nFactorCoeff).ToArray(),
@@ -108,4 +109,54 @@
       return solution;
     }
+
+    public static IRegressionSolution CreateSolution(IRegressionProblemData problemData, out double rmsError, out double cvRmsError) {
+      IEnumerable<string> doubleVariables;
+      IEnumerable<KeyValuePair<string, IEnumerable<string>>> factorVariables;
+      double[,] inputMatrix;
+      PrepareData(problemData, out inputMatrix, out doubleVariables, out factorVariables);
+
+      alglib.linearmodel lm = new alglib.linearmodel();
+      alglib.lrreport ar = new alglib.lrreport();
+      int nRows = inputMatrix.GetLength(0);
+      int nFeatures = inputMatrix.GetLength(1) - 1;
+
+      int retVal = 1;
+      alglib.lrbuild(inputMatrix, nRows, nFeatures, out retVal, out lm, out ar);
+      if (retVal != 1) throw new ArgumentException("Error in calculation of linear regression solution");
+      rmsError = ar.rmserror;
+      cvRmsError = ar.cvrmserror;
+
+      // get parameters of the model
+      double[] w;
+      int nVars;
+      alglib.lrunpack(lm, out w, out nVars);
+
+      // ar.c is the covariation matrix,  array[0..NVars,0..NVars].
+      // C[i, j] = Cov(A[i], A[j])
+
+      var solution = new LinearRegressionModel(w, ar.c, cvRmsError, problemData.TargetVariable, doubleVariables, factorVariables)
+        .CreateRegressionSolution((IRegressionProblemData)problemData.Clone());
+      solution.Name = "Linear Regression Solution";
+      return solution;
+    }
+
+    private static void PrepareData(IRegressionProblemData problemData,
+      out double[,] inputMatrix,
+      out IEnumerable<string> doubleVariables,
+      out IEnumerable<KeyValuePair<string, IEnumerable<string>>> factorVariables) {
+      var dataset = problemData.Dataset;
+      string targetVariable = problemData.TargetVariable;
+      IEnumerable<string> allowedInputVariables = problemData.AllowedInputVariables;
+      IEnumerable<int> rows = problemData.TrainingIndices;
+      doubleVariables = allowedInputVariables.Where(dataset.VariableHasType<double>);
+      var factorVariableNames = allowedInputVariables.Where(dataset.VariableHasType<string>);
+      factorVariables = dataset.GetFactorVariableValues(factorVariableNames, rows);
+      double[,] binaryMatrix = dataset.ToArray(factorVariables, rows);
+      double[,] doubleVarMatrix = dataset.ToArray(doubleVariables.Concat(new string[] { targetVariable }), rows);
+      inputMatrix = binaryMatrix.HorzCat(doubleVarMatrix);
+
+      if (inputMatrix.ContainsNanOrInfinity())
+        throw new NotSupportedException("Linear regression does not support NaN or infinity values in the input dataset.");
+    }
     #endregion
   }
Index: /stable/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/LinearRegressionModel.cs
===================================================================
--- /stable/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/LinearRegressionModel.cs	(revision 17074)
+++ /stable/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/LinearRegressionModel.cs	(revision 17074)
@@ -0,0 +1,161 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Problems.DataAnalysis;
+
+namespace HeuristicLab.Algorithms.DataAnalysis {
+  /// <summary>
+  /// Represents a linear regression model
+  /// </summary>
+  [StorableClass]
+  [Item("Linear Regression Model", "Represents a linear regression model.")]
+  public sealed class LinearRegressionModel : RegressionModel, IConfidenceRegressionModel {
+    public static new Image StaticItemImage {
+      get { return HeuristicLab.Common.Resources.VSImageLibrary.Function; }
+    }
+
+    [Storable]
+    public double[,] C {
+      get; private set;
+    }
+    [Storable]
+    public double[] W {
+      get; private set;
+    }
+
+    [Storable]
+    public double NoiseSigma {
+      get; private set;
+    }
+
+    public override IEnumerable<string> VariablesUsedForPrediction {
+      get { return doubleVariables.Union(factorVariables.Select(f => f.Key)); }
+    }
+
+    [Storable]
+    private string[] doubleVariables;
+    [Storable]
+    private List<KeyValuePair<string, IEnumerable<string>>> factorVariables;
+
+    /// <summary>
+    /// Enumerable of variable names used by the model including one-hot-encoded of factor variables.
+    /// </summary>
+    public IEnumerable<string> ParameterNames {
+      get {
+        return factorVariables.SelectMany(kvp => kvp.Value.Select(factorVal => $"{kvp.Key}={factorVal}"))
+          .Concat(doubleVariables)
+          .Concat(new[] { "<const>" });
+      }
+    }
+
+    [StorableConstructor]
+    private LinearRegressionModel(bool deserializing)
+      : base(deserializing) {
+    }
+    private LinearRegressionModel(LinearRegressionModel original, Cloner cloner)
+      : base(original, cloner) {
+      this.W = original.W;
+      this.C = original.C;
+      this.NoiseSigma = original.NoiseSigma;
+
+      doubleVariables = (string[])original.doubleVariables.Clone();
+      this.factorVariables = original.factorVariables.Select(kvp => new KeyValuePair<string, IEnumerable<string>>(kvp.Key, new List<string>(kvp.Value))).ToList();
+    }
+    public LinearRegressionModel(double[] w, double[,] covariance, double noiseSigma, string targetVariable, IEnumerable<string> doubleInputVariables, IEnumerable<KeyValuePair<string, IEnumerable<string>>> factorVariables)
+      : base(targetVariable) {
+      this.name = ItemName;
+      this.description = ItemDescription;
+      this.W = new double[w.Length];
+      Array.Copy(w, W, w.Length);
+      this.C = new double[covariance.GetLength(0), covariance.GetLength(1)];
+      Array.Copy(covariance, C, covariance.Length);
+      this.NoiseSigma = noiseSigma;
+      this.doubleVariables = doubleInputVariables.ToArray();
+      // clone
+      this.factorVariables = factorVariables.Select(kvp => new KeyValuePair<string, IEnumerable<string>>(kvp.Key, new List<string>(kvp.Value))).ToList();
+    }
+
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() {
+    }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new LinearRegressionModel(this, cloner);
+    }
+
+    public override IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) {
+      double[,] inputData = dataset.ToArray(doubleVariables, rows);
+      double[,] factorData = dataset.ToArray(factorVariables, rows);
+
+      inputData = factorData.HorzCat(inputData);
+
+      int n = inputData.GetLength(0);
+      int columns = inputData.GetLength(1);
+
+      for (int row = 0; row < n; row++) {
+        double p = 0.0;
+        for (int column = 0; column < columns; column++) {
+          p += W[column] * inputData[row, column];
+        }
+        p += W[columns];
+        yield return p;
+      }
+    }
+
+    public IEnumerable<double> GetEstimatedVariances(IDataset dataset, IEnumerable<int> rows) {
+      double[,] inputData = dataset.ToArray(doubleVariables, rows);
+      double[,] factorData = dataset.ToArray(factorVariables, rows);
+
+      inputData = factorData.HorzCat(inputData);
+
+      int n = inputData.GetLength(0);
+      int columns = inputData.GetLength(1);
+
+      double[] d = new double[C.GetLength(0)];
+
+      for (int row = 0; row < n; row++) {
+        for (int column = 0; column < columns; column++) {
+          d[column] = inputData[row, column];
+        }
+        d[columns] = 1;
+
+        double var = 0.0;
+        for (int i = 0; i < d.Length; i++) {
+          for (int j = 0; j < d.Length; j++) {
+            var += d[i] * C[i, j] * d[j];
+          }
+        }
+        yield return var + NoiseSigma * NoiseSigma;
+      }
+    }
+
+    public override IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {
+      return new ConfidenceRegressionSolution(this, new RegressionProblemData(problemData));
+    }
+  }
+}
