Assign fitlme output to a variable

3 views (last 30 days)
Is there a way to output specific fitlme parameters? Specifically, how can I assign the t-statistic value to a specified variable? I see how to output the entire fitlme model, but not how to extract a specific value in a function.

Accepted Answer

Torsten
Torsten on 4 Feb 2025
Edited: Torsten on 4 Feb 2025
See
The functions that can be applied to a fitlme object are:
anova Analysis of variance for linear mixed-effects model
coefCI Confidence intervals for coefficients of linear mixed-effects model
coefTest Hypothesis test on fixed and random effects of linear mixed-effects model
compare Compare linear mixed-effects models
covarianceParameters Extract covariance parameters of linear mixed-effects model
designMatrix Fixed- and random-effects design matrices
fitted Fitted responses from a linear mixed-effects model
fixedEffects Estimates of fixed effects and related statistics
partialDependence Compute partial dependence
plotPartialDependence Create partial dependence plot (PDP) and individual conditional expectation (ICE) plots
plotResiduals Plot residuals of linear mixed-effects model
predict Predict response of linear mixed-effects model
random Generate random responses from fitted linear mixed-effects model
randomEffects Estimates of random effects and related statistics
residuals Residuals of fitted linear mixed-effects model
response Response vector of the linear mixed-effects model
  2 Comments
Michael Higley
Michael Higley on 4 Feb 2025
Thanks- ultimate solution per your suggestion was to use anova(lme), convert that output into an array, and extract the F stat and p value.
Torsten
Torsten on 4 Feb 2025
Usually it's done like in this example:
load imports-85
tbl = table(X(:,12),X(:,14),X(:,24),'VariableNames',{'Horsepower','CityMPG','EngineType'});
lme = fitlme(tbl,'CityMPG~Horsepower+(1|EngineType)+(Horsepower-1|EngineType)');
out = anova(lme)
out =
ANOVA MARGINAL TESTS: DFMETHOD = 'RESIDUAL' Term FStat DF1 DF2 pValue {'(Intercept)'} 170.4 1 201 1.3147e-28 {'Horsepower' } 30.581 1 201 9.8848e-08
out.FStat
ans = 2×1
170.3980 30.5807
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
out.pValue
ans = 2×1
1.0e-07 * 0.0000 0.9885
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2024b

Community Treasure Hunt

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

Start Hunting!