Regstats : Multiple regression/comparing regression slopes
显示 更早的评论
Hi,
I want to compare the regression slopes of 3 data sets. Apparently you have to set some dummy variables =0/1 and regress against them to do this.
So I tried to do it using regstats but I can't get regstats to work with several regressors.
I tried the following :
X =
% the "real" regressor (1 2 3) repeated 3 times (one for each set)
1
2
3
1
2
3
1
2
3
Z12 =
% the first dummy regressor (1 if data is from set number 2)
0
0
0
1
1
1
0
0
0
Z20 =
% second dummy regressor (1 if data is from group 3)
0
0
0
0
0
0
1
1
1
V=[X,Z12,Z20]
V =
% all three regressors put together in one matrix
1 0 0
2 0 0
3 0 0
1 1 0
2 1 0
3 1 0
1 0 1
2 0 1
3 0 1
Y=2+3*X+4*Z12+5*Z20*X'
Y =
% fake dataset to see if regstats would give me the right coefficients
35
38
41
39
42
45
35
38
41
then i tried
s=regstats(Y,V,'interactions','all')
and got the following warnings
Warning: Matrix is singular to working precision.
> In regstats at 180
Warning: Matrix is singular to working precision.
> In regstats at 195
and none of the numbers is correct i get a lot of NaNs and Inf for example
>> s.beta
ans =
NaN
NaN
NaN
NaN
NaN
NaN
Inf
I don't have any clue on what is wrong with the code I tried. I have never used regstats before. Any idea on what I could do ?
Thank you very much for your help !
3 个评论
Oleg Komarov
2012-3-16
Y=2+3*X+4*Z12+5*Z20*X' doesn't give the output you wrote but
Y=2+3*X+4*Z12+5*Z20'*X does
why are you doing that? Do you have lagged values of X in your model?
laurie
2012-3-17
Oleg Komarov
2012-3-17
The thread you found is a good one, follow it thoroughly and pay attention to details, for example .* is different from *
采纳的回答
更多回答(1 个)
laurie
2012-3-17
0 个投票
1 个评论
Oleg Komarov
2012-3-17
You usually read things like, the p-values are too high, thus the coefficients are not statistically significant at any conentional level (where the conventional levels are 5% or 1%).
A p-value is the (smallest) probability to observe a value that is different from the null just by chance.
Rephrasing, a p-value is the percentage of values you would erroneously accept (when they should be considered as the null).
In regressions, the p-value of single coefficients is ususally the t-test against the null of 0.
So, say you have a coefficient of 0.32 and the question you want to ask is: "is it truly 0.32 or should I consider it as 0?"
Suppose you get a p-value of 9.81%. It says that the probability of 0.32 being a 0 is 9.81%.
Now, are you willing to accept such a risk? Usually, the threshold is 5%, thus observing a p-value lower than the threshold is good sign.
DISCLAIMER: I am abusing the words truly and accept.
Truly is with respect to the assumed distribution for your parameters and you NEVER accept the NULL but you fail to reject it.
类别
在 帮助中心 和 File Exchange 中查找有关 Model Building and Assessment 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!