BookmarkSubscribeRSS Feed
haze0025
Calcite | Level 5

I have a set of data consisting of daily expenses for dairy cows for the first 4 years after they join the milking herd (at around 2 years of age).  My objective is to compare 2 different breeds of cows for these daily expenses.

 

I'm having a problem with 1 expense variable, growing cost, which is all assigned on day 1 after first calving, so most cows have a cost of around $1,425 on day 1 with a range of roughly $900 to $1,800.  A value of $0 is assigned for every day of the rest of their lives (up to a max of 1461 days).  Some cows had short lifespans and so may only have 100 days of lifetime; therefore, 100 rows in the data.  Other cows lived all 4 years and so have 1461 rows, but again with only the growing cost on day 1.  I want to assign a weight to every day of each cow's life, such that these 2 example cows have equal weight in the analysis.  I did this simply by assigning dayweight=1/lifespan.

 

However, when I run "WEIGHT dayweight;" in the model, I get back least squares means that are way to high and nonsensical.  Here is my model statement code:

 

proc hpmixed data=have;
class herd breed sire;
model growcost=herd breed;
random sire(breed);
test herd breed/htype=3;
weight dayweight;
lsmeans herd breed/pdiff;
run;quit;

 

My LSmeans without the weight statement make sense--Breed 1=$1.92 per day, Breed 2=$1.77 per day, and these very closely match the raw means.

However, with using the WEIGHT statement, I get Breed 1=$24.81 per day, and Breed 2=$16.50 per day.

 

What I am doing wrong?  Thanks in advance for your suggestions!

1 REPLY 1
Rick_SAS
SAS Super FREQ

You say you have 100 records in the data if the cow lives 100 days. That doesn't make sense to me because you also say that a cow might have GrowCost = 1200 for the first day but then you assign GFrowCost=0 for the other 99 days. That doesn't lead to a sound model.

 

It seems that none of your variables are changing during the life of a cow, so you should have one observation per cow and drop the weight variable.

 

If you want to compute the daily cost per cow, you can add LifeSpan the data and model the rate. See how to model rates in SAS.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1 reply
  • 352 views
  • 0 likes
  • 2 in conversation