BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

Good day SAS friends:

Well, first to thank you a lot because all you help is usefull in my current research, well here i go with the last step of my avaliation, lets begin:

As you know, the growing models are very usefull in many biological ares, specially in animal nutrition, there fore, this example is the resume os a dataset of 5000 animals in average, the reason that im posting this is i will not beable to do this manually, and SAS can help very much. My example has 3 animals observed in the time, and weighted  (repeated measures) several times to obtain the eficience and growing parameters of them.

here is the data base:

data have;
input Animal    age_in_days    weight_in_Kilograms;
cards;
1    11    10.00
1    21    10.20
1    31    10.21
1    41    10.22
1    45    10.45
1    50    10.60
2    43    11.00
2    45    11.30
2    49    11.35
2    60    11.30
2    65    12.20
2    70    12.50
2    76    12.65
2    80    13.00
2    95    14.00
2    105   16.00
3    10    11.00
3    20    11.00
3    33    11.00
3    43    11.20
4    44    11.65
4    45    12.00
4    46    13.00
4    50    13.00
4    60    13.50
;

Untill here everything is good, to evaluate the eficience in the growing rate of each animal i need to obtain a new variable called "Mean daily Weight Gain", this explains in average the the weight gained from the begining day to the next (final) day, for example:

The animal number 1 began to be weighted at the 11th day of the experiment with an observed weight of ten (10) kilograms and the next measure (of the same animal) at the 21th day is about 10.20 kilograms, this means clearly that in 10 days this animal gained 200 grams, and in average 0.02 Kg each day, to find this we can asume the next formula:

(Final weight - Initial weight)/(Final day - Initial day) = (10.2 - 10.0)/(21 - 11)=0.02 Kilograms

As you can see, this measure offers the observed weight gained using 2 measures, but the big problem is that i need several measures to trust in this result. The way to make it posible is to obtain the weight gained for each measure, well i constructed a table in excel to visualiza better this methodology:

 

Animal Age_in_days Weight_In_Kilograms          
1 11 10.000          
1 21 10.200 0.020        
1 31 10.210 0.011 0.001      
1 41 10.220 0.007 0.001 0.001    
1 45 10.450 0.013 0.010 0.017 0.057  
1 50 10.600 0.015 0.014 0.021 0.042 0.030

 

This tables shows what i explained before, i took the age of 11 days and 21 days and their respective weights, and could be obtained de gain (IN RED). So the numbers in "bold" represent the weight gained using the next age as the initial measure, in ORANGE we can see the last measure or weight gain, taking the 45 as the inicial day and 50 as the final measure with 10.45 and 10.60 kilograms respectively, in here was obtained 0.03 Kg.

 

Until now, we want to obtain the weight gained using 2 measures (the initial and the final), but once obtained all the means, i could perormance and general average like this:

 

0.020        
0.011 0.001      
0.007 0.001 0.001    
0.013 0.010 0.017 0.057  
0.015 0.014 0.021 0.042 0.030
Total Average 0.017      

 

Here the value os 0.017 means the total average of the complete set of means obtained en the past step. with this we can conclude that the animal 1 in 39 days, begining in the day 11 and finishing in the day 50 of the experiment, accomplished an average weght gain daily of 0.017. This we can traduce into an new table:

 

Animal

 

Animal Avegare_Gain_by-day
1 0.017

 

This mus to be done for all the animals in the data set (data have) i proposed in the beginig of the post.

 

So i hope you to help me, i will thank you for ever.

 

Big regards and thank you very much

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Your estimator of weight gain is very similar to Sen's estimator of slope, also called Theil-Sen estimator or Kendall estimate of slope, see 

https://en.wikipedia.org/wiki/Theil%E2%80%93Sen_estimator

It is easy to calculate:

 

data have;
input Animal age weight;
cards;
1    11    10.00
1    21    10.20
1    31    10.21
1    41    10.22
1    45    10.45
1    50    10.60
2    43    11.00
2    45    11.30
2    49    11.35
2    60    11.30
2    65    12.20
2    70    12.50
2    76    12.65
2    80    13.00
2    95    14.00
2    105   16.00
3    10    11.00
3    20    11.00
3    33    11.00
3    43    11.20
4    44    11.65
4    45    12.00
4    46    13.00
4    50    13.00
4    60    13.50
;
proc sql;
create table slopes as
select 
    a.animal, 
    median( (b.weight-a.weight) / (b.age-a.age) ) as senSlope
from
    have as a inner join 
    have as b on a.animal=b.animal and a.age<b.age
group by a.animal;
select * from slopes;
quit;

You may replace the median by the mean, but the median is more robust (less sensitive to outliers).

 

PG

View solution in original post

5 REPLIES 5
PGStats
Opal | Level 21

Your estimator of weight gain is very similar to Sen's estimator of slope, also called Theil-Sen estimator or Kendall estimate of slope, see 

https://en.wikipedia.org/wiki/Theil%E2%80%93Sen_estimator

It is easy to calculate:

 

data have;
input Animal age weight;
cards;
1    11    10.00
1    21    10.20
1    31    10.21
1    41    10.22
1    45    10.45
1    50    10.60
2    43    11.00
2    45    11.30
2    49    11.35
2    60    11.30
2    65    12.20
2    70    12.50
2    76    12.65
2    80    13.00
2    95    14.00
2    105   16.00
3    10    11.00
3    20    11.00
3    33    11.00
3    43    11.20
4    44    11.65
4    45    12.00
4    46    13.00
4    50    13.00
4    60    13.50
;
proc sql;
create table slopes as
select 
    a.animal, 
    median( (b.weight-a.weight) / (b.age-a.age) ) as senSlope
from
    have as a inner join 
    have as b on a.animal=b.animal and a.age<b.age
group by a.animal;
select * from slopes;
quit;

You may replace the median by the mean, but the median is more robust (less sensitive to outliers).

 

PG
jonatan_velarde
Pyrite | Level 9

Good morning PG:

 

I have tested your procedure and it work perfectly.

 

You are a genious

 

Thank you very much

jonatan_velarde
Pyrite | Level 9

One more time thank you for your answer:

 

One question went out during my data procesing, and it is:

 

using the code you provided here:

 

proc sql;
create table slopes as
select 
    a.animal, 
    median( (b.weight-a.weight) / (b.age-a.age) ) as senSlope
from
    have as a inner join 
    have as b on a.animal=b.animal and a.age<b.age
group by a.animal;
select * from slopes;
quit;

How could i do to use the mean of the observations, with no interference of using the age???

 

Thanks you very much

PGStats
Opal | Level 21

Not sure I understand your question. Sen's slope is the median of all the slopes between pairs of points. You could replace the median with the mean, if you prefer. It should give you about the same values, anyway.

PG
SteveDenham
Jade | Level 19

This makes some very VERY large assumptions about growth over these time periods.  This assumes that growth rate is independent of initial body weight and of mature body size, and where the individual is on the growth trajectory--all of which are inaccurate, especially when it come to estimating efficiency.  While this is an interesting approach to growth and efficiency from a mathematical point of view, it doesn't fit well with the known literature.  See, for example, Mercer (1980) Mathematical models in nutrition. Nutr. Rept Int. 21, 189-198 and Mercer et al. (1979) Prediction of food intakes and growht rates in weanling rats by the four-parameter model equation. Nutr. Rept. Int, 19, 1-8.

 

This would provide a good starting parameter for nonlinear modeling.

 

Steve Denham

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!

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
  • 5 replies
  • 2148 views
  • 2 likes
  • 3 in conversation