Linear regression : How to take into account the quadratic term only and not the linear term ?
    7 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
Hello everyone,
I am currently working on a linear regression using the fitlm tool. I collect my datas from a table name "newT2" that has 3 columns.
Here is my code :
modelaction = 'Var1 ~ Var2 + Var3^2';
mdlaction = fitlm(newT2, modelaction);
The problem is that the regression is done according this equation : 'Var1 ~ Var2 + Var3+ Var3^2'. But it's not what I asked, I don't want the linear term Var3.
In fact, if I run with the equation 'Var1 ~ Var2 + Var3^3', the regression is done according : 'Var1 ~ Var2 + Var3+ Var3^2 + Var3^3' and so on.
Thanks for your help !
1 Commento
Risposte (1)
  Star Strider
      
      
 il 22 Apr 2022
        Suppress the intercept term and the linear ‘Var3’ by negating them — 
newT2 = array2table(rand(7,3))                              % Create Data Table
modelaction = 'Var1 ~ - 1 + Var2 - Var3 + Var3^2';          % Specify Model
mdlaction = fitlm(newT2, modelaction)
.
0 Commenti
Vedere anche
Categorie
				Scopri di più su Linear and Nonlinear Regression in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!