Monte Carlo hypothesis test
显示 更早的评论
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
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
2017-10-27
编辑:M Fernandes
2017-10-28
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Hypothesis Tests 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!