turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- how to determine the meal criterion point

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-12-2012 11:14 PM

Hello everyone:

I'm a PhD candidate majoring in animal science in China.

As in your book which titled "SAS/STAT 9.3 User's Guide - The FMM Procudure (Chapter)", example 37.2 from page 2533-2541 illustrates when do cows eat.

I'm so interested in the content of one sentence "The point at which the second and third components cross over is used to separate feeding events into meals." which appears at page 2533.

However, the point's information mentioned above can not be found throughout this chapter. A small issue I wish to concern about is, which data or process in the FMM procedure offer hints to represent the value of this point at which the pdf of the two populations cross?

Thanks you allowing me for sharing my problem. Your reply may be highly appreciated

Best regards!

*James Xu*

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-13-2012 09:30 AM

My first comment is that if you want to separate the events into meals, it probably suffices to simply look at the picture and estimate the crossing visually. It doesn't make much difference to the cows whether the time is 9:00am or 9:07am.

However, if you want a rigorous solution, let f1 and f2 be the two densities for which you wish to find the crossing point. (Use the estimated parameters from PROC FMM.) Then the function f(x) - f1(x)-f2(x) is zero at the crossing point, and you can find the zero by using any numerical root-finding method. For example, in the SAS/IML 12.1 language you can use the FROOT function:

proc iml;

start func(x);

f1 = pdf("Normal", x, 0, 1); /* density of N(0,1) */

f2 = pdf("Normal", x, 1, 2); /* density of N(1,2), where 2 is std dev */

return( f1 - f2 );

finish;

x = froot("Func", {0 3});

print x;

If you are running a version of SAS/IML prior to 12.1, you can use the bisection module to find the root. See Finding the root (zero) of a function in SAS

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-14-2012 02:54 AM

Dear Rick:

Thanks so much for your reply, and it must give me good suggestion to solve my question.

Given the accurate data which I want to obtain, the function and method referring to FROOT function is preferred.

In strict accordance with your statement in SAS/IML 12.1, I try to fix these statements in your example illustrating the distribution of Scrabble® scores which is characterized by a mixture of two normal distributions upon your score.

proc iml;

start func(x);

f1 = pdf("Normal", x, 21.7, 6.7); /* density of N(21.7,6.7), where 2 is std dev in your example*/

f2 = pdf("Normal", x, 37.3, 3);

return( f1 - f2 );

finish;

x = froot("Func", {27 37});

print x;

However, after performing, the error terms occur : "Matrix x has not been set to a value".

What does it mean? And any errors in my statements?? If have, could you please tell me??

Thank you for your helpful assistance.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-14-2012 06:29 AM

Your code is correct. My guess is you don't have SAS/IML 12.1. Check the LOG to see If you are getting an error such as "ERROR: the FROOT function is not found."

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-15-2012 12:08 AM

Thanks for reminding, my SAS sofeware actually have a little problems when installing, FROOT function is not available in my computer, but the bisection method is OK. Then I change the statement as below:

proc iml;

start func(x);

f1 = pdf("Normal", x, 12.7, 6.7); /* density of N(12.7,6.7), where 6.7 is std dev in your example*/

f2 = pdf("Normal", x, 37.3, 3);

return( f1 - f2 );

finish;

start bisection(a, b);

dx = 1e-6; dy = 1e-4;

do i = 1 to 100;

c = (a+b)/2;

if abs(func(c)) < dy | (b-a)/2 < dx then

return(c);

if func(a)#func(c) > 0 then a = c;

else b = c;

end;

return (.);

finish;

z = bisection(27, 37);

print z;

Then the SAS procedure determines the solution is "Z=29.03".

Is the statement mentioned above right or wrong?

By the way, you said that the function f(x) - f1(x)-f2(x) is zero at the crossing point,but why return(f1-f2) in the func(x), is that meaning f1(x)-f2(x)=0???

Looking forward your friendly answer!

Many thanks and best regards!