BookmarkSubscribeRSS Feed
fatso33
Obsidian | Level 7

Dear Friends

 

I am running the following code on for my thesis. But i donot know how to fix the error or adjust the matrix operation...

 

%let m=1; * Number of replicates at each concentration level;
proc iml;
* Import the data sets;
use b; read all into b;
use covb; read all into covb;
* Initialize matrices;
y=j(101,1,0);
h=j(101,1,0);
hy=j(101,1,0);
hb=j(101,4,0);
varx0=j(101,1,0);
pp=j(101,1,0);
top=b[1];
bottom=b[2];
c50=b[3];
slope=b[4];
* Calculate the precision profile;
do i=1 to 101;
h[i,1]=10**(log10(&minconc)+(i-1)*(log10(&maxconc)-log10(&minconc))/100);
y[i,1]=top+(bottom-top)/(1+(h[i,1]/c50)**slope);
hy[i,1]=h[i,1]*(top-bottom)/(slope*(bottom-y[i,1])*(y[i,1]-top));
hb[i,1]=h[i,1]/(slope*(y[i,1]-top));
hb[i,2]=h[i,1]/(slope*(bottom-y[i,1]));
hb[i,3]=h[i,1]/c50;
hb[i,4]=-h[i,1]*log((bottom-y[i,1])/(y[i,1]-top))/(slope**2);
varx0[i,1]=((hy[i,1]**2)*&sigma_sq*(y[i,1]**(2*&theta))/&m)+hb[i,]*covb*hb[i,];
pp[i,1]=100*sqrt(varx0[i,1])/h[i,1];
end;
create plot var{h hy y pp};
append;
quit;

 

Here is the error:

 


1621 proc iml;
NOTE: IML Ready
1622 * Import the data sets;
1623 use b;
1623! read all into b;
1624 use covb;
1624! read all into covb;
1625 * Initialize matrices;
1626 y=j(101,1,0);
1627 h=j(101,1,0);
1628 hy=j(101,1,0);
1629 hb=j(101,4,0);
1630 varx0=j(101,1,0);
1631 pp=j(101,1,0);
1632 top=b[1];
1633 bottom=b[2];
1634 c50=b[3];
1635 slope=b[4];
1636 * Calculate the precision profile;
1637 do i=1 to 101;
1638 h[i,1]=10**(log10(&minconc)+(i-1)*(log10(&maxconc)-log10(&minconc))/100);
1639 y[i,1]=top+(bottom-top)/(1+(h[i,1]/c50)**slope);
1640 hy[i,1]=h[i,1]*(top-bottom)/(slope*(bottom-y[i,1])*(y[i,1]-top));
1641 hb[i,1]=h[i,1]/(slope*(y[i,1]-top));
1642 hb[i,2]=h[i,1]/(slope*(bottom-y[i,1]));
1643 hb[i,3]=h[i,1]/c50;
1644 hb[i,4]=-h[i,1]*log((bottom-y[i,1])/(y[i,1]-top))/(slope**2);
1645 varx0[i,1]=((hy[i,1]**2)*&sigma_sq*(y[i,1]**(2*&theta))/&m)+hb[i,]*covb*hb[i,];
1646 pp[i,1]=100*sqrt(varx0[i,1])/h[i,1];
1647 end;
ERROR: (execution) Matrices do not conform to the operation.

operation : * at line 1645 column 72
operands : _TEM1011, _TEM1012

_TEM1011 1 row 4 cols (numeric)

-0.000769 1.4782E-8 -0.000619 -0.000557

_TEM1012 1 row 4 cols (numeric)

-1.157735 -0.053985 0.2209224 -0.249582

statement : ASSIGN at line 1645 column 1

 

I did understand the problem at hand but how to rectify the problem is the headache....please anyone help me....I got a thesis deadline

4 REPLIES 4
PaigeMiller
Diamond | Level 26

At line 1645, column 72, you are doing a matrix multiplication, but the matrices do not conform to the operation.

 

For matrix multiplication to work, if you have matrix A which is n rows and m columns and matrix B has m rows and p columns, then the result of A*B is n x p.

 

The error message indicates that you have m1 columns in A and m2 rows in B, and m1 not equal to m2.

--
Paige Miller
fatso33
Obsidian | Level 7

thank you very much paige....I had sort of picked up that but I was struggling to modify the matrices. This is a code from a text book im using for my project

PaigeMiller
Diamond | Level 26

That specific line of code is:

 

varx0[i,1]=((hy[i,1]**2)*&sigma_sq*(y[i,1]**(2*&theta))/&m)+hb[i,]*covb*hb[i,];

and somehow you are trying to multiply a 1x4 matrix with a 1x4 matrix, that should give you some idea about what needs to be fixed.

--
Paige Miller
fatso33
Obsidian | Level 7

wow thank you so much paige.....that is really helpful