Help with Proc GLM Code

Reply
New Contributor
Posts: 2

Help with Proc GLM Code

Hi Everybody,

I am trying to write some code but I am getting some strange results.

I initiated a study where I took soil cores and I then made a number of measurements, on each core, for a variety of food web metrics.   I took cores in three distinct desert habitats. In each habitat, I selected 6 trees, which I am treating as a plot.   At each tree, I took 4 soil cores at two positions, relative to the tree trunk.  I took 2 cores near the trunk and two cores in the bare area in close proximity. I refer to this as position.   I repeated this whole sampling scheme at three dates, under all the same trees (season).

My research question is "How do soil characteristics change by habitat, position, and season"?

I wrote up a bit of code, which I present below. Some assumptions that I am making is the tree is a repeating variable in the model since I took cores at the same sets of trees over the course of the study.   Another assumption that I am making is that habitat type and position (canopy vs. bare area) are both nested in tree.

proc glm;

class position habitat season tree;

model lv1-lv45= season | habitat(tree) | position(tree);

repeated tree;

lsmeans season | habitat | position/pdiff;

run;

quit;

I would like to partition my results into the following in the ANOVA output:

Position

Habitat

Season

Position* Habitat

Position*Season

Habitat*Season

Position* Habitat*Season

I am getting some strange output and several of my interactions are reporting 0 degrees of freedom.  Would somebody mind reviewing my assumptions of nestedness and habitat? I think combining the nested variable with the repeating variable is the source of my errors. If you see an error in my code, would you mind pointing it out?

Thank you!

Karl

Respected Advisor
Posts: 3,777

Re: Help with Proc GLM Code

I can't answer your question, but I have a question.  Does the data set output by the following program model the data from your experiment?  Number of obs, factor, levels, etc.

proc plan ordered;
  
factor
      habitat=
3
      tree=
6
      position=
2
      sample=
2
      season=
3
      / noprint;
   output out=plan;
   run;
data plan;
   set plan;
   y=rannor(1); *one of your core measurements;
  
run;
proc print;
  
run;
New Contributor
Posts: 2

Re: Help with Proc GLM Code

Dear data_null_;

Thank you for taking the time to review my post and write a response, I really appreciate it.

I ran the code you provide the factor # and observations match between the proc GLM and proc Plan, as you asked about.

I explain below:

The GLM Procedure

                                       Class Level Information

                Class         Levels    Values

                position           2    1 2

                habitat            3    1 2 3

                season             3    1 2 3

                tree              18    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

                               Number of Observations Read         216

                               Number of Observations Used         216

                                        

Proc Plan Procedure

# of Obs. - 216

Factors for Season - 3

Factors for Habitat - 3

Factors for Tree - 6 (6 trees in each habitat)

Factor for Position - 2


I hope this answers your question.

Karl

Respected Advisor
Posts: 3,777

Re: Help with Proc GLM Code

Bump: 2

While I think you should have consulted a statistician before conducting your experiment so you would know the answer to these questions and not have to seek advice here I still don't know why all of the statisticians have been silent on this topic.

Does the forum really make that much difference?  I usually just look at the most recient content but then I read the forum "every" day.

Message was edited by: data _null_

Super User
Posts: 17,819

Re: Help with Proc GLM Code

Because its not in the Statistics Forum

Trusted Advisor
Posts: 1,613

Re: Help with Proc GLM Code

I am getting some strange output and several of my interactions are reporting 0 degrees of freedom.  Would somebody mind reviewing my assumptions of nestedness and habitat? I think combining the nested variable with the repeating variable is the source of my errors. If you see an error in my code, would you mind pointing it out?

Statistician speaking up:

Zero degrees of freedom always means your design does not allow you to estimate all the terms in the model. Or to put things a different way, it means that some of your interactions are completely confounded with each other, or completely confounded with main effects. Since its too late to change the design, the only thing you can do is to take some terms out of the model, and then you should wind up with all terms having positive degrees of freedom, but that does not eliminate the confounding, it only eliminates zero degrees of freedom from the model, and your effect estimates and still confounded. Sometimes the ALIASING option in PROC GLM can provide the information needed to determine what interactions are confounded with other terms in the model.

In other words, the error may not be in your code, the error may be the design of the experiment.

Ask a Question
Discussion stats
  • 5 replies
  • 345 views
  • 0 likes
  • 4 in conversation