BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
palolix
Pyrite | Level 9

Dear SAS Community,

 

I am using a polynomial regression since the relationship between the outcome var DTR (continuous) and Harvest month (categorical) appears to be curvilinear.  I would like to predict DTR (days to ripe) when the fruits were harvested in Jan (1) and Feb (2). Since I am not sure if my estimates are correct, I would greatly appreciate your feedback. I have seven harvest months in total (1,2,3,4,5,6,8).

 

ods graphics on;
proc glm data=one;
Where Wks<6;
class Harvest;
model DTR= Harvest Harvest*Harvest/solution alpha=.05 clparm;
estimate "pred DTR when Harvest=1" intercept 1 Harvest 1 0 0 0 0 0 0;
estimate "pred DTR when Harvest=2" intercept 1 Harvest 0 1 0 0 0 0 0;

run;
ods graphics off;

 

The GLM Procedure
 
Dependent Variable: DTR

 

Source DF Sum of Squares Mean Square F Value Pr > F
Model 6 2061.513304 343.585551 47.34 <.0001
Error 554 4020.971545 7.258071    
Corrected Total 560 6082.484848      

R-Square Coeff Var Root MSE DTR Mean
0.338926 35.00184 2.694081 7.696970

Source DF Type I SS Mean Square F Value Pr > F
Harvest 6 2061.513304 343.585551 47.34 <.0001

Source DF Type III SS Mean Square F Value Pr > F
Harvest 6 2061.513304 343.585551 47.34 <.0001

Parameter Estimate Standard
Error
t Value Pr > |t| 95% Confidence Limits
pred DTR when Harvest=1 10.8666667 0.24593480 44.19 <.0001 10.3835879 11.3497454
pred DTR when Harvest=2 8.8292683 0.42074473 20.98 <.0001 8.0028182 9.6557184

Parameter Estimate   Standard
Error
t Value Pr > |t| 95% Confidence Limits
Intercept 7.625000000 B 0.24593480 31.00 <.0001 7.141921263 8.108078737
Harvest 1 3.241666667 B 0.34780434 9.32 <.0001 2.558490165 3.924843169
Harvest 2 1.204268293 B 0.48735004 2.47 0.0138 0.246988411 2.161548175
Harvest 3 -0.075000000 B 0.49186961 -0.15 0.8789 -1.041157474 0.891157474
Harvest 4 -1.200000000 B 0.38885707 -3.09 0.0021 -1.963814549 -0.436185451
Harvest 5 -0.725000000 B 0.49186961 -1.47 0.1411 -1.691157474 0.241157474
Harvest 6 -2.250000000 B 0.34780434 -6.47 <.0001 -2.933176502 -1.566823498
Harvest 8 0.000000000 B . . . . .

 

Note: The X'X matrix has been found to be singular, and a generalized inverse was used to solve the normal equations. Terms whose estimates are followed by the letter 'B' are not uniquely estimable.

 
palolix_3-1731525614561.png

 

 

 

 

 

Thank you very much!



 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
Yeah. It looks good to me.
And you can simple your code by using LSMEANS instead of use ESTIMATE :

estimate "pred DTR when Harvest=1" intercept 1 Harvest 1 0 0 0 0 0 0;
estimate "pred DTR when Harvest=2" intercept 1 Harvest 0 1 0 0 0 0 0;
---->
lsmeans Harvest/cl ;

View solution in original post

8 REPLIES 8
Ksharp
Super User
"polynomial" is usually for continuous variable,not class variable, like :Quadratic/Cubic term .
why you have interact term 'Harvest*Harvest' in your model?
palolix
Pyrite | Level 9
Thank you for replying! So outcome var and predictor var need to be continuous in order to fit a polynomial regression?
Ksharp
Super User
predictor var need to be continuous.
That is my opinion. I don't know if others would tell you another story.
palolix
Pyrite | Level 9
Ok good to know. So since the relationship between my categorical predictor and outcome var is not linear and the distribution of residuals is skewed to the right I guess I will then fit a model with genmod using gamma or log transform the outcome var.
Thank you very much Ksharp!
Ksharp
Super User
categorical/nomial predictor and continuous outcome var can not have linear relationship.
linear relationship is just for two continuous variables.
palolix
Pyrite | Level 9

Ok thank you, good to know.  

 

So is this model appropriate for the categorical predictor Harvest (7 levels) and the continuous var DTR?

 

proc glm data=one order=freq ;
Where Wks<6;
class Harvest;
model DTR=Harvest /solution  ss3 alpha=.05 clparm;
estimate "pred DTR when Harvest=1" intercept 1 Harvest 1 0 0 0 0 0 0;
estimate "pred DTR when Harvest=2" intercept 1 Harvest 0 1 0 0 0 0 0;
run;
quit;

 

The GLM Procedure
 
Dependent Variable: DTR

 

Source DF Sum of Squares Mean Square F Value Pr > F
Model 6 2061.513304 343.585551 47.34 <.0001
Error 554 4020.971545 7.258071    
Corrected Total 560 6082.484848      

R-Square Coeff Var Root MSE DTR Mean
0.338926 35.00184 2.694081 7.696970

Source DF Type III SS Mean Square F Value Pr > F
Harvest 6 2061.513304 343.585551 47.34 <.0001

Parameter Estimate Standard
Error
t Value Pr > |t| 95% Confidence Limits
pred DTR when Harvest=1 10.8666667 0.24593480 44.19 <.0001 10.3835879 11.3497454
pred DTR when Harvest=2 5.3750000 0.24593480 21.86 <.0001 4.8919213 5.8580787

Parameter Estimate   Standard
Error
t Value Pr > |t| 95% Confidence Limits
Intercept 6.900000000 B 0.42597158 16.20 <.0001 6.063283083 7.736716917
Harvest 1 3.966666667 B 0.49186961 8.06 <.0001 3.000509192 4.932824141
Harvest 6 -1.525000000 B 0.49186961 -3.10 0.0020 -2.491157474 -0.558842526
Harvest 8 0.725000000 B 0.49186961 1.47 0.1411 -0.241157474 1.691157474
Harvest 4 -0.475000000 B 0.52170650 -0.91 0.3630 -1.499764753 0.549764753
Harvest 2 1.929268293 B 0.59873025 3.22 0.0013 0.753209236 3.105327350
Harvest 3 0.650000000 B 0.60241478 1.08 0.2811 -0.533296412 1.833296412
Harvest 5 0.000000000 B . . . . .

 

 

Ksharp
Super User
Yeah. It looks good to me.
And you can simple your code by using LSMEANS instead of use ESTIMATE :

estimate "pred DTR when Harvest=1" intercept 1 Harvest 1 0 0 0 0 0 0;
estimate "pred DTR when Harvest=2" intercept 1 Harvest 0 1 0 0 0 0 0;
---->
lsmeans Harvest/cl ;
palolix
Pyrite | Level 9

Great, thank you so much Ksharp!!

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 8 replies
  • 1641 views
  • 5 likes
  • 2 in conversation