Statistical programming, matrix languages, and more

# between two vectors

Reply
Occasional Contributor
Posts: 5

# between two vectors

Hello,

I am a french student and i am studying an article where there is a SAS/IML code.

In this code, DES is a matrix of parameters, DELTA and EST are vectors. Delta={0,0,0,0} and EST is the vector of parameter estimates.

We calculate lambda=exp(DES*(-EST)) so lambda is a vector.

Then, to calculate the exposure at different time intervals (4 intervals) until time t=0 :

lambda_delta_t1=lambda # DELTA


In my application, # don't work because lambda and delta are vectors. I don't know how to do and I don't understand.

Thank you
SAS Employee
Posts: 94

Re: # between two vectors

The # operator is element-wise multiplication, so it should work with two vectors provided the dimensions match up correctly. Both operands should be the same type (m x 1 or 1 x m) vector and have the same number of elements. It would be helpful to look at the article to better understand the author's intentions.
Occasional Contributor
Posts: 5

Re: # between two vectors

http://aje.oxfordjournals.org/content/171/7/837.full

You can see the code in appendix 3.

Thank you very much
Occasional Contributor
Posts: 5

Re: # between two vectors

Hello,

Can you at least explain to me what # should do between 2 vectors.
For example:

A={1,2,3,4};
B={5,6};

Is A#B={ 1*5 2*5 3*5 4*5,
1*6 2*6 3*6 4*6}

or A#B={1*5 1*6,
2*5 2*6,
3*5 3*6,
4*5 4*6}
?
Occasional Contributor
Posts: 5

Re: # between two vectors

Hi,

The code you posted just results in an error as the dimensions of both vectors don't match.

You can find the answer to your question in the following blog post.

http://blogs.sas.com/iml/index.php?/archives/48-Shorthand-Notation-for-Row-and-Column-Operations.htm...

Nicolas
Occasional Contributor
Posts: 5

Re: # between two vectors

Hi,

My dimensions are correct according to the article:
lambda is a vector with 4304 rows
delta is a vector with 4 rows

I need to understand what the result of this operation is, to compute it on R.

What I have done today, but I think it's not correct because my final result are negative and they don't have to be it's:

lambda # delta = matrix with 4304 rows and 4 columns where
column i is lambda*delta(i)

Do you think I am right ?

The blog don't talk about operation between two vectors, and it's my problem. Message was edited by: Adeline34000
Occasional Contributor
Posts: 5

Re: # between two vectors

PLease, nobody can tell me what result # should give between two vectors??
Occasional Contributor
Posts: 5

Re: # between two vectors

It doesn't do anything as the dimensions don't match up. If you execute the code as you say you get errors.
Ask a Question
Discussion stats
  • 7 replies
  • 350 views
  • 0 likes
  • 3 in conversation