![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/896300/image.png)
wald test of equality in matlab.
조회 수: 10 (최근 30일)
이전 댓글 표시
Hello
I am running a nonlinear impulse response with positive shock and negative shock for each period. Suppose for period one, i have a positive shock value as 3.2 and negative shock value as -4.8. I need a formal test to show that the two shocks are not equal that is (positive ≠ negative). I have values for period 1-12.
Kindly assist.
댓글 수: 1
Star Strider
2022년 2월 16일
The Wald test is a test on parameters. From the description provided, it does not appear to be appropriate here.
If it is appropriate here, it would appear to be relatively straightforward to code, and the Statistics and Machine Learning Toolbox can calculate the appropriate
probabilities.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/896300/image.png)
채택된 답변
Aditya
2024년 1월 21일
Hi mpho,
The Wald test is typically used to test the significance of individual coefficients in a model or to test the equality of two parameters in the context of a statistical model. However, from the description provided, it seems you are looking to test whether the effects of positive and negative shocks are significantly different from each other, rather than testing model parameters.
If you have estimated impulse responses for both positive and negative shocks across different periods and you want to test if the responses are statistically different, you might consider using a paired difference test, such as the paired t-test, if the assumptions for this test are met (e.g., the differences are normally distributed).
Here is an example of how you might perform a paired t-test in MATLAB using the Statistics and Machine Learning Toolbox for a simple case where you have estimated impulse responses for positive and negative shocks for 12 periods:
positiveShocks = [3.2, ...]; % replace with your actual values
negativeShocks = [-4.8, ...]; % replace with your actual values
% Calculate the differences between positive and negative shocks
differences = positiveShocks - negativeShocks;
% Perform a paired t-test
[h, p, ci, stats] = ttest(differences);
% Display the results
if h == 1
fprintf('Reject the null hypothesis at the 5% significance level.\n');
fprintf('p-value: %g\n', p);
fprintf('Confidence interval on the mean difference: [%g, %g]\n', ci(1), ci(2));
else
fprintf('Do not reject the null hypothesis at the 5% significance level.\n');
fprintf('p-value: %g\n', p);
end
In this code, 'h' is the hypothesis test result (1 if the test rejects the null hypothesis, 0 otherwise), 'p' is the p-value of the test, 'ci' is the confidence interval of the mean difference, and 'stats' contains the test statistic and degrees of freedom.
Remember to check the assumptions of the paired t-test before applying it. If the assumptions are not met, you may need to consider non-parametric alternatives, such as the Wilcoxon signed-rank test, which can be performed in MATLAB using the “signrank” function.
For additional details on “ttest” function refer to the below MATLAB documentation:
I hope you find this information useful!
댓글 수: 0
추가 답변 (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!