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

How do i write a code for the equation below:

|a - b| - E|a - b|.

where E represents an expectation operator, while a and b are variables

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

Equation (3) is the PDF of the binomial distribution. In SAS, you can use the PDF function to compute the binomial density.

The standard definition is 

pdf = PDF("Binomial", numSuccess, prob, NumTrials);

 

For your notation:

pdf = PDF("Binomial", X_it, P_Bar, N_it);

View solution in original post

7 REPLIES 7
PaigeMiller
Diamond | Level 26

SAS does not have a way to compute expected values of a distribution.

 

Are you trying to use the "mean of the data" instead of the "Expected value of a distribution"?

--
Paige Miller
Rick_SAS
SAS Super FREQ

Since E[A-B] = E[A] - E[B], this reduces to the expected value of a single random variable (rv).

If A and B are discrete r.v.'s, the expected value is a sum: E[X] = SUM( X_i * p_i ).

If they are continuous r.v.'s, then you are computing the means of the distributions. For many standard distributions, the mean has an explicit value in terms of the parameters of the distribution. For nonstandard distributions, you can compute the integral of x*f(x) over the support of the distribution. The QUAD function in SAS/IML can perform integrations like this.

 

Princeelvisa
Obsidian | Level 7

Thanks for your response, i forgot to add that the expectation is calculated based on the
Binomial Distribution.

In the above question, i tried to simplify the real question.

please find attached pictures that explain the full question. 

How do i find equation 2, especially the second term using SAS.

Thank you

Princeelvisa_0-1586333505497.pngPrinceelvisa_1-1586333555045.png

 

Rick_SAS
SAS Super FREQ

Equation (3) is the PDF of the binomial distribution. In SAS, you can use the PDF function to compute the binomial density.

The standard definition is 

pdf = PDF("Binomial", numSuccess, prob, NumTrials);

 

For your notation:

pdf = PDF("Binomial", X_it, P_Bar, N_it);

Princeelvisa
Obsidian | Level 7

Thanks Rick for your response,

Please in using the pdf as you specified above, how do i determine P_bar (prob) ?

Thank you

Rick_SAS
SAS Super FREQ

The reference says that \bar{P}_t is the "cross-sectional average" of the P_{it}, which means averaged over the i, I suppose.

 

I don't have time to help you understand the paper, but perhaps others do. As always, the best way to get a good answer is to post data and the SAS code you are currently using. Good luck!

Princeelvisa
Obsidian | Level 7

Thank you Rick, i did it with your help. Thanks again  👍

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 7 replies
  • 2643 views
  • 2 likes
  • 3 in conversation