Monte Carlo hypothesis test

3 ビュー (過去 30 日間)
M Fernandes
M Fernandes 2017 年 10 月 27 日
編集済み: M Fernandes 2017 年 10 月 28 日
Dear Matlab users, I want to do a Monte Carlo simulation of a test of a nonlinear hypothesis, my null hypothesis is beta1*beta2=1. I am using the following code:
alpha=1;
beta1=0.5;
beta2=2;
n=100;
m=10;
beta1_hat=zeros(m,1);
for i=1:m
x1=randn(n,1);
x2=randn(n,1);
e=randn(n,1);
y=alpha+beta1*x1+beta2*x2+e;
end
[h,pvalue,ci]=ttest(beta1*beta2,1)
However, when I run the code, I obtain the following: h = NaN pvalue = NaN ci = NaN NaN
I used this code for the hypothesis testing, following this: https://www.mathworks.com/help/stats/hypothesis-testing.html . Another question that I have is why do they divide by 100 price2 in the ttest?
Thanks!
  2 件のコメント
Brendan Hamm
Brendan Hamm 2017 年 10 月 27 日
beta1*beta2 is a scalar and so is 1 and there are not enough samples to perform any hypothesis test. Are you trying to estimate the beta coefficients from the linear equation? If this is the case, then you likely want to be using y somewhere, which you currently aren't.
M Fernandes
M Fernandes 2017 年 10 月 27 日
編集済み: M Fernandes 2017 年 10 月 28 日
Thank you, Brendan Hamm for your answer.
What I want to do is, considering a multiple linear regression model, propose a test statistic to test the nonlinear hypothesis that the product of the slopes of two explanatory equals one (in the model y=β1+β2X2+β3X3+ε test the null hypothesis that H0: β2×β3=1).
I tried to rethink in my code:
beta1=1;
beta2=0.5;
beta3=2;
n=100;
m=1000;
beta_hat=zeros(m,1);
for i=1:m
x1=randn(n,1);
x2=randn(n,1);
e=randn(n,1);
y=beta1+beta2*x1+beta3*x2+e;
X1=[ones(n,1) x1];
beta_hatvec2=(inv(X1'*X1))*X1'*y;
X2=[ones(n,1) x2];
beta_hatvec3=(inv(X2'*X2))*X2'*y;
beta_hat2(i)=beta_hatvec2(2);
beta_hat3(i)=beta_hatvec3(2);
end
[h]=ttest(beta_hat2*beta_hat3,1)
But know Matlab tells me
"Error using *
Inner matrix dimensions must agree."

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeHypothesis Tests についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by