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

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
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-11-2014 05:29 AM

The matrix r is (2*t-1)*(2*t-1) but is it empty..may you help me?

Besides, I need to start the do from a negative number is this o.k.??

This is the program:

proc iml;

t=15;

a=2*t;

r=j(a-1,a-1,.);

do i= (1-t) to (t-1);

do j= (1-t) to (t-1);

az1= -(j-i);

az2= -(j-i);

bz1= -(j-i);

bz2= (j-i);

cz1= (j-i);

cz2= (j-i);

if j<0 then z1=az1;

z2=az2;

if j=0 then z1=bz1;

z2=bz2;

if j>0 then z1=cz1;

z2=cz2;

r[i,j]=probnorm(z2)-probnorm(z1);

end;

end;

print r;

quit;

Thanks in advance.

Waiting for your reply.

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

06-11-2014 06:34 AM

The program gives invalid subscript errors for the matrix r, since both i and j can be zero or negative. I suspect you need to change it to r[i+t, j+t] = ....

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

Posted in reply to IanWakeling

06-11-2014 07:25 AM

Thanks for your help.

I have just tried what you suggested. The matrix is now filled with numbers but they are not correct.

Why did you suggested putting (+t)?

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

06-11-2014 07:43 AM

If you declare a 29x29 matrix then you can only reference individual elements within it by using the integers 1 to 29 as row or column subscript indices. You were trying to use -14 to +14 as the indices, so my suggestion was to shift it back to the correct range by adding 15.

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

06-14-2014 06:39 AM

Since we don't know what numbers are correct, you need to tell us what you expect or give an example for t=3.

The correctness of the program depends on z2 and z1. You can check their correctness with the following:

1) Outside the loop, allocate

Lower=j(a-1,a-1,.);

Upper=j(a-1,a-1,.);

2) Within the loop, define

Lower[i+t,j+t] = z1;

Upper[i+t,j+t] = z2;

3) Print Lower and Upper after the loop.

BTW, since the normal CDF is effectively zero when z<-6 and is 1 when z>6, you can probably get by with a smaller value of t. In any case, switch from PROBNORM(z) to CDF("Normal",z), as suggested at the end of this article: Six reasons you should stop using the RANUNI function to generate random numbers - The DO Loop