1、多元线性回归模型代码using System;/using System.Math;public class MatrixMultiplypublic static void Main()int a, b, p = 0;/Console.WriteLine(“该程序将求出两个矩阵的积:“);Console.WriteLine(“请问所用模型为几元模型?:“);b = int.Parse(Console.ReadLine();b = b + 1;Console.WriteLine(“请指定数据时间段数:“);a = int.Parse(Console.ReadLine();double, Mat
2、rixX = new doublea, b;for (int i = 0; i M)M=Math.Abs (MatrixBi,k);p = i;/Console.WriteLine(“p= “+p);for (int i = k; i = 0; i-)N = 0;for (int j = i + 1; j b; j+)/for (int c = 0; c 1; c+)/N += MatrixBi, j * MatrixCj, 0;/Console.WriteLine(“此时数 N为:“+N);/for (int j = i + 1; j b; j+)/for (int j = 0; j 1;
3、j+)MatrixCi, 0 = (MatrixCi, 0 - N) / MatrixBi, i;/Console.WriteLine(“所求的参数矩阵为:“);outputMatrix(MatrixC, b, 1);int c;Console.WriteLine(“请指定要预测的时间段:“);c = int.Parse(Console.ReadLine();double, MatrixD = new doublec, b;Console.WriteLine(“请输入要预测时间段的参数矩阵:“);for (int i = 0; i c; i+)for (int j = 1; j b; j+)/
4、Console.WriteLine(“请输入矩阵 X第0行第1列的值:“, i + 1, j + 1);MatrixDi, j = double.Parse(Console.ReadLine();MatrixD i,0=1;outputMatrix(MatrixD, c, b);double, MatrixYUCE = new doublec,1;for (int i = 0; i c; i+)for (int j = 0; j b; j+)MatrixYUCEi, 0 += MatrixDi, j * MatrixCj, 0;Console.WriteLine(“所要预测的数据为:“);outputMatrix(MatrixYUCE, c, 1);private static void outputMatrix(double, MatrixX, double rowCount,double columnCount)for (int i = 0; i rowCount; i+)for (int j = 0; j columnCount; j+)Console.Write(MatrixXi, j + “t“);Console.WriteLine();.