您如何使用大数据进行假设检验?我编写了以下 MATLAB 脚本来强调我的困惑。它所做的只是生成两个随机序列,并对另一个变量进行简单的线性回归。它使用不同的随机值多次执行此回归并报告平均值。往往会发生的情况是,当我增加样本量时,p 值平均变得非常小。
我知道,因为检验的能力随着样本量的增加而增加,给定足够大的样本,p 值将变得足够小,即使是随机数据,也可以拒绝任何假设检验。我四处打听,有人说“大数据”更重要的是看效果大小,即。测试是否显着以及是否具有足够大的影响让我们关心。这是因为在大样本量中,p 值会发现非常小的差异,就像这里解释的那样。
但是,效果大小可以通过数据的缩放来确定。下面我将解释变量缩放到足够小的量级,即给定足够大的样本量,它对因变量有很大的显着影响。
所以我想知道,如果存在这些问题,我们如何从大数据中获得任何洞察力?
%make average
%decide from how many values to make average
obs_inside_average = 100;
%make average counter
average_count = 1;
for average_i = 1:obs_inside_average,
%do regression loop
%number of observations
n = 1000;
%first independent variable (constant term)
x(1:10,1) = 1;
%create dependent variable and the one regressor
for i = 1:10,
y(i,1) = 100 + 100*rand();
x(i,2) = 0.1*rand();
end
%calculate coefficients
beta = (x'*x)\x'*y;
%calculate residuals
u = y - x*beta;
%calcuatate sum of squares residuals
s_2 = (n-2)\u'*u;
%calculate t-statistics
design = s_2*inv(x'*x);
%calculate standard errors
stn_err = [sqrt(design(1,1));sqrt(design(2,2))];
%calculate t-statistics
t_stat(1,1) = sqrt(design(1,1))\(beta(1,1) - 0);
t_stat(2,1) = sqrt(design(2,2))\(beta(2,1) - 0);
%calculate p-statistics
p_val(1,1) = 2*(1 - tcdf(abs(t_stat(1,1)), n-2));
p_val(2,1) = 2*(1 - tcdf(abs(t_stat(2,1)), n-2));
%save first beta to data column 1
data(average_i,1) = beta(1,1);
%save second beta to data column 2
data(average_i,2) = beta(2,1);
%save first s.e. to data column 3
data(average_i,3) = stn_err(1,1);
%save second s.e. to data column 4
data(average_i,4) = stn_err(2,1);
%save first t-stat to data column 5
data(average_i,5) = t_stat(1,1);
%save second t-stat to data column 6
data(average_i,6) = t_stat(2,1);
%save first p-val to data column 7
data(average_i,7) = p_val(1,1);
%save second p-val to data column 8
data(average_i,8) = p_val(2,1);
end
%calculate first and second beta average
b1_average = mean(data(:,1));
b2_average = mean(data(:,2));
beta = [b1_average;b2_average];
%calculate first and second s.e. average
se1_average = mean(data(:,3));
se2_average = mean(data(:,4));
stn_err = [se1_average;se2_average];
%calculate first and second t-stat average
t1_average = mean(data(:,5));
t2_average = mean(data(:,6));
t_stat = [t1_average;t2_average];
%calculate first and second p-val average
p1_average = mean(data(:,7));
p2_average = mean(data(:,8));
p_val = [p1_average;p2_average];
beta
stn_err
t_stat
p_val