Error using linearmodel object in function called by Simevents
古いコメントを表示
Hi,
I want to use predicted value from a regression model in my Simevents simulation. The entity server will take some entity attributes as input to call the myFUN and use the output as another attribute of the entity. So I built a regression model in workspace, which is a .mat object in LinearModel class. And I wrote myFUN that takes a new set of predictor values and outputs the predicted value. myFUN looks like this:
function [los] = myLOS(age,admit_type,classification_type,case_specialty,gender)
mod = load('los_mod1.mat','los_mod1');
admit_type = categorical(admit_type);
classification_type = categorical(classification_type);
case_specialty = categorical(case_specialty);
gender = categorical(gender);
tbl_new = table(age,admit_type,classification_type,case_specialty,gender);
tbl_new.Properties.VariableNames = {'AGE','admit_type_1','classification_type_1','case_specialty_1','gender_key_1'};
los_log = predict(mod.los_mod1,tbl_new);
los = exp(los_log);
end
The function works fine when I call it in command line, but when I run the simulation, it gives the below error: Found unsupported class for variable using function 'load'. MATLAB class 'LinearModel' found at 'mod.los_mod1' is unsupported.
This is the first time I use MATLAB and I cannot figure out what to do.Is there another way than to hard-calculate the predicted value using coefficients and dummy variables?
Hope this is clear to you all. And hope someone can enlighten! :) Thanks a lot!
Joy
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Discrete-Event Simulation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!