BookmarkSubscribeRSS Feed
kawyant
Calcite | Level 5

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

5 REPLIES 5
data_null__
Jade | Level 19

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;
kawyant
Calcite | Level 5

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

data_null__
Jade | Level 19

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_

Reeza
Super User

Because its not in the Statistics Forum

PaigeMiller
Diamond | Level 26

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.

--
Paige Miller

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1304 views
  • 0 likes
  • 4 in conversation