coefficient p-values in fitglm are all NaN

25 次查看(过去 30 天)
hi,
I am trying to use fitglm, and keep getting NaN for all the p-values of the betas, even though the t statistics are computed.
This happens even when I run matlab's examples.
For example:
load hospital
dsa = hospital;
modelspec = 'Smoker ~ Age*Weight*Sex - Age:Weight:Sex';
mdl = fitglm(dsa,modelspec,'Distribution','binomial')
I get the same results as in the example, except all the p-values are NaN.
Any advice would be highly appreciated.
  10 个评论
dpb
dpb 2021-7-23
编辑:dpb 2021-7-24
>> load hospital
dsa = hospital;
modelspec = 'Smoker ~ Age*Weight*Sex - Age:Weight:Sex';
mdl = fitglm(dsa,modelspec,'Distribution','binomial')
mdl =
Generalized linear regression model:
logit(Smoker) ~ 1 + Sex*Age + Sex*Weight + Age*Weight
Distribution = Binomial
Estimated Coefficients:
Estimate SE tStat pValue
___________ _________ ________ _______
(Intercept) -6.0492 19.749 -0.3063 0.75938
Sex_Male -2.2859 12.424 -0.18399 0.85402
Age 0.11691 0.50977 0.22934 0.81861
Weight 0.031109 0.15208 0.20455 0.83792
Sex_Male:Age 0.020734 0.20681 0.10025 0.92014
Sex_Male:Weight 0.01216 0.053168 0.22871 0.8191
Age:Weight -0.00071959 0.0038964 -0.18468 0.85348
100 observations, 93 error degrees of freedom
Dispersion: 1
Chi^2-statistic vs. constant model: 5.07, p-value = 0.535
>> ver
-----------------------------------------------------------------------------------------------------
MATLAB Version: 9.9.0.1592791 (R2020b) Update 5
...
>>
Oh. This is also on Windows (old machine, still Win7 though).
Prabhjot Dhami
Prabhjot Dhami 2022-2-26
I'm running into the same issue (with the example data) with Matlab 2021b on Mac.
Did anyone else figure out how to solve this issue?

请先登录,再进行评论。

回答(2 个)

Samaneh Nemati
Samaneh Nemati 2021-7-23
@the cyclist Hi, I am using MATLAB R2019b and trying to use fitglm function, but it returns only NANs in the output "mdl". Here I attached the "Data.mat" file which includes the X and Y (predictors and resposne) and also the output of the fitglm ("mdl"). And below is the command I used. Do you know what I am doing wrong?
mdl = fitglm(X,Y,'linear','Distribution','normal');
  4 个评论
xiaoyu
xiaoyu 2023-3-1
I tested whether this replication failure was due to the different versions of matlab.
I tested this possibility on three PCs and one MAC with different matlab versions.
1 on the first PC,
I tried on 2020b on my PC, all pvalues nan;
2022a on PC, all pvalues nan.
2on the second PC,
2020b, all pvalues were normal;
3on the third PC,
2020b, all pvalues nan;
2022a, all pvalues nan.
4on MAC
2018a on MAC, all pvalues were normal...
really confusing....
xiaoyu
xiaoyu 2023-3-1
update: 2022b matlab fixed this problem out of nowhere...

请先登录,再进行评论。


xiaoyu
xiaoyu 2023-3-2
I have solved this problem by following the suggestions from Guru Kumaresan from MathWorks Technical Support Team:
This might happen because some function is being shadowed by another function. I would suggest you to restore your default paths by following the steps given below:
1)You can take a backup of your search path by executing the following command to give you the location of the search path.
>> which -all pathdef
Before proceeding, you should backup this file by copying it to a folder outside of your MATLAB path. This step is optional and only matters you if you have customized 'pathdef.m' by adding custom paths.
2) After making the backup, please execute the following commands in the MATLAB Command Window to restore the default MATLAB search path and rehash the toolbox cache:
>> restoredefaultpath
>> rehash toolboxcache
3) After this step, please use MATLAB again to see if the issue persists. If the issue is resolved, then you can save the new MATLAB search path by executing the following command:
>> savepath
  1 个评论
Philipp
Philipp 2024-9-27
I was running into similar problems on Matlab 2024a using MacOs Monterey. Problems could be resolved simply by restoredefaultpath. P-values were reported without any trouble. Thanks!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Analysis of Variance and Covariance 的更多信息

标签

产品


版本

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by