Define a set of independent variables for fitlm
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
alpedhuez
el 6 de Dic. de 2020
Comentada: Star Strider
el 7 de Dic. de 2020
Suppose I have a table T with labels
visitors price proxy_January proxy_February proxy_March
I want to run a regression
visitors = a + b*price + c_1*proxy_January + ...
A brute force way is to write down
X=[T.price T.proxy_January (then the rest of proxy variables)]
and run
mdl = fitlm(X,T.visitors)
But I would like to have Matlab to write down all the proxy variables instaad of me listing all by hand.
I understand that I can get the list of labels with T.Properties.VariableNames but I need to get the list of labels and data. Please advise.
0 comentarios
Respuesta aceptada
Star Strider
el 6 de Dic. de 2020
Possibly:
X = T{:,2:end};
then:
mdl = fitlm(X,T.visitors)
If ‘T’ has only numeric variables, that should work. .
4 comentarios
Star Strider
el 7 de Dic. de 2020
As always, my pleasure!
(My apologies for the delay in responding.)
Más respuestas (0)
Ver también
Categorías
Más información sobre Tables en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!