SAS/IML Software and Matrix Computations

Statistical programming, matrix languages, and more
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
mattll218
Calcite | Level 5

Hi all! I am in a course that works strictly with SAS. I am by no means any expert in SAS but I have gotten by previously fairly OK, and I am attempting to get better with the program. I was with a bad professor last semester and got the same professor this semester (I cannot switch out or do another course unfortunately). I have tried to reach out to my professor for help and all I got was a pretty snarky reply that didn't provide me any help or insight, so I am posting here in hopes that I might get some actual help into what I am doing incorrectly in my code. The problem I am having issues with relate to generating a graph that shows the relationship between x variable and the corresponding log-likelihood. When I attempt to generate it, I either get a small, finite line or nothing graphed at all. What should be graphed is a curve (see media image). I have attached the code key to the first assignment, as well as my own code to the 1st and 2nd assignment. The proc sgplot is the last lines of code in each document. Any insight or help at all would be appreciated as I cannot identify what exactly I am doing wrong and I would like to get better!

mattll218_0-1738445055413.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hi @mattll218 and welcome to the SAS Support Communities!

 

Sorry to hear that your professor didn't help you. 

 

I see a common issue in your two programs regarding the graph: The range of x-values doesn't include the value of interest, i.e., the argument maximizing the log-likelihood function. In the program for HW 1 that x-value is p2=-58.7143, whereas your DO loop

do i =1 to 250;
  p2=-100+(i-1)*0.01;
...
end;

covers only the range from -100 through -97.51 (=-100+(250-1)*0.01). Compare this to the corresponding loop in the code key

do i =1 to 200;
  p2=-68.5+(i*0.1);
...
end;

where the range of p2 values from -68.4 through -48.5 is (almost) centered around -58.7143.

 

Similarly, in your program for HW 2 the mu range from -50 through -38.02 doesn't contain 124.20, which seems to be the mu value of interest according to your REFLINE statement.

 

So, in both cases adjust the step size and/or the ending value of the DO loop in order to include the relevant portion of the graph.

 

I hope that this resolves the issue because, lacking a SAS/IML license, I can't be of much help regarding the IML code (but other community experts can).

 

 

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

Hi @mattll218 and welcome to the SAS Support Communities!

 

Sorry to hear that your professor didn't help you. 

 

I see a common issue in your two programs regarding the graph: The range of x-values doesn't include the value of interest, i.e., the argument maximizing the log-likelihood function. In the program for HW 1 that x-value is p2=-58.7143, whereas your DO loop

do i =1 to 250;
  p2=-100+(i-1)*0.01;
...
end;

covers only the range from -100 through -97.51 (=-100+(250-1)*0.01). Compare this to the corresponding loop in the code key

do i =1 to 200;
  p2=-68.5+(i*0.1);
...
end;

where the range of p2 values from -68.4 through -48.5 is (almost) centered around -58.7143.

 

Similarly, in your program for HW 2 the mu range from -50 through -38.02 doesn't contain 124.20, which seems to be the mu value of interest according to your REFLINE statement.

 

So, in both cases adjust the step size and/or the ending value of the DO loop in order to include the relevant portion of the graph.

 

I hope that this resolves the issue because, lacking a SAS/IML license, I can't be of much help regarding the IML code (but other community experts can).

 

 

mattll218
Calcite | Level 5

Thank you! This did indeed fix the issue I was facing and now I know what I need to adjust/look for in the future! I appreciate you taking the time to look at the code and respond!

sas-innovate-white.png

Join us for our biggest event of the year!

Four days of inspiring keynotes, product reveals, hands-on learning opportunities, deep-dive demos, and peer-led breakouts. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 2 replies
  • 1606 views
  • 2 likes
  • 2 in conversation