![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/896300/image.png)
wald test of equality in matlab.
5 次查看(过去 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!