如何在Matlab的循环外添加回归显着性分析

时间:2019-04-06 10:06:58

标签: matlab statistics regression

我对每个纬度/经度坐标进行了30年温度变化的回归分析。我想获得有关温度随时间变化的重要性的回归统计数据(p值或t检验显着性值),但尺寸必须与斜率相同(即192x288)。

I have tried for example:
whichstats = {'tstat','rsquare'};
stats = regstats(y_t2mirrm1,x,'linear',whichstats);
tstat = stats.tstat;
rsquare = stats.rsquare;

但是尺寸仅为1个数字或1个展开的矢量(1x13000)。

这是我的线性回归代码:


    % initialise time parameters
    time_begin  = [1981, 1, 1, 0,0,0];
    time_end    = [2010,12,31,23,0,0];
    years       = (time_begin(1):time_end(1))';
    nyears      = length(years);
    % create storage and regress
    TXx = randi(100, 288, 192, 30);
    lat = rand(192, 1);
    lon = rand(288, 1);
    time = rand(30,1);
    M = numel(lon);
    N = numel(lat);
    slope = zeros(M, N);
    intercept = zeros(M, N);
    T = numel(time);
    x = ([ones(T, 1) years]);
    % Regress each lat/lon location
    for i = 1 : M
        for j = 1 : N
            % Get all time instances of each lat/lon location
            y = squeeze(TXx(i, j, :));
            % Create regression problem and solve
            c = regress(y, x);
            intercept(i, j) = c(1);
            slope(i, j) = c(2);      
        end
    end

预期结果应该是每个斜率的p值(尺寸-192x288或288x192)。

0 个答案:

没有答案