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

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
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.

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
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.

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
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.

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.

 

This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.

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

 

This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.

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);

This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.

Thanks Rick for your response,

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

Thank you

This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.

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!

This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.

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

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!

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
  • 3824 views
  • 2 likes
  • 3 in conversation
This widget could not be displayed.
This widget could not be displayed.