Monte Carlo hypothesis test
조회 수: 2 (최근 30일)
이전 댓글 표시
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.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Hypothesis Tests에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!