[vsni.co.uk] Contact us
Author Message
Post new topic

  GenStat  ~  Use of SUBMAT function to get pieces of a symmetric matrix

Rodger White
Posted: Mon Aug 06, 2018 2:27 pm Reply with quote
Guest
Andrew,
You can also use qualified identifiers as below. The rules for qualified identifiers can be quite complicated but if you use the same kind of structure on either side of the assignment then the results are straightforward


symmetric [row=4; val=1...10] sma
calc smb = sma$[!(1,2)]
print smb
calc smc = sma$[!(3,4)]
print smc

Rodger

Rodger White
Statistics Group
Centre for Computational and Systems Biology
Rothamsted Research
West Common
Harpenden
Herts
AL5 2JQ
e-mail: rodger.white@rothamsted.ac.uk
Tel: 01582938378(direct line)
Tel: 01582763133 ext 2378

-----Original Message-----
From: GENSTAT-Request [mailto:GENSTAT@jiscmail.ac.uk] On Behalf Of Andrew McLachlan
Sent: 01 August 2018 23:57
To: GENSTAT@JISCMAIL.AC.UK
Subject: Re: Use of SUBMAT function to get pieces of a symmetric matrix

Thankyou David for the explanation of SUBMAT.
I had completely forgotten about the ELEMENTS function, but am now using it to get the values I want, thanks to your clear example code.

Cheers,
Andrew Mc

Andrew McLachlan
Biometrician

-----Original Message-----
From: GENSTAT-Request [mailto:GENSTAT@jiscmail.ac.uk] On Behalf Of David Baird
Sent: Wednesday, 1 August 2018 5:18 p.m.
To: GENSTAT@JISCMAIL.AC.UK
Subject: Re: Use of SUBMAT function to get pieces of a symmetric matrix

Dear Andrew,

SUBMAT assumes that the matrix has a pointer for the rows labels.

VARIATE W,X,Y,Z
SYMMETRIC [ROWS=!P(W,X,Y,Z)] SX; VALUES=!(1...10) PRINT SX; DEC=0 SYMMETRIC [ROWS=!P(W,X)] S1 CALC S1 = SUBMAT(SX) PRINT S1; DEC=0

If you want to access by position use the ELEMENTS function with two arguments (one for rows and one for columns). You need to type the results as symmetric matrices or else the will come out as regular matrices:

SYMMETRIC [4] S; !(1...10)
SYMMETRIC S1,S2
CALC First,Last = !(1...2),!(3...4)
CALC S1,S2 = ELEMENT(2(S);First,Last;First,Last)
PRINT S1,S2; DEC=0

Regards, David.
______________________________________________
Dr David Baird Statistical Consultant and GenStat Developer VSN (NZ) Limited (David@VSN.CO.NZ)
8 Mariposa Crescent, Aidanfield, Christchurch 8025, New Zealand Ph +64 3 3350588 Cell +64 21 1160803

-----Original Message-----
From: GENSTAT-Request <GENSTAT@jiscmail.ac.uk> On Behalf Of Andrew McLachlan
Sent: 1 August 2018 4:54 PM
To: GENSTAT@JISCMAIL.AC.UK
Subject: Use of SUBMAT function to get pieces of a symmetric matrix

Hi All

I want to get sub-triangles from a symmetric matrix. The Help has lead me to the SUBMAT function, but after reading the Help I still don't understand how to get the function to work. Does anyone have a simple example that they could show me?

For example, with a symmetric matrix with four rows:
1
2, 3
4, 5, 6
7, 8, 9, 10

I wish to get sub-triangles:
1
2, 3

and
6
9, 10


Cheers,
Andrew Mc

Andrew McLachlan
Biometrician



T: +64 6 355 6110
M: +64 212581882
F: +64 6 351 7050
E: andrew.mclachlan@plantandfood.co.nz
https://emea01.safelinks.protection.outlook.com/?url=www.plantandfood.co.nz&amp;data=01%7C01%7Crodger.white%40ROTHAMSTED.AC.UK%7Cf5eaf46dd17f464bb4da08d5f80212f4%7Cb688362589414342b0e37b8cc8392f64%7C1&amp;sdata=stWoMg4S6xPkq3QhHeFGVdrSqN4D8KpYfQ7TnumDigA%3D&amp;reserved=0
The New Zealand Institute for Plant & Food Research Limited

Postal Address: Plant & Food Research
Private Bag 11600, Palmerston North 4442, New Zealand Physical Address:
Plant & Food Research Food Industry Science Centre, Fitzherbert Science Centre, Batchelar Road, Palmerston North 4474, New Zealand

The contents of this e-mail are confidential and may be subject to legal privilege.
If you are not the intended recipient you must not use, disseminate, distribute or reproduce all or any part of this e-mail or attachments. If you have received this e-mail in error, please notify the sender and delete all material pertaining to this e-mail. Any opinion or views expressed in this e-mail are those of the individual sender and may not represent those of The New Zealand Institute for Plant and Food Research Limited.

########################################################################

To unsubscribe from the GENSTAT list, click the following link:
https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.jiscmail.ac.uk%2Fcgi-bin%2Fwebadmin%3FSUBED1%3DGENSTAT%26A%3D1&amp;data=01%7C01%7Crodger.white%40ROTHAMSTED.AC.UK%7Cf5eaf46dd17f464bb4da08d5f80212f4%7Cb688362589414342b0e37b8cc8392f64%7C1&amp;sdata=7ClOHILllHxyctwFuO9EhPkgKnd2D3nAIEp9S6HFoYo%3D&amp;reserved=0

########################################################################

To unsubscribe from the GENSTAT list, click the following link:
https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.jiscmail.ac.uk%2Fcgi-bin%2Fwebadmin%3FSUBED1%3DGENSTAT%26A%3D1&amp;data=01%7C01%7Crodger.white%40ROTHAMSTED.AC.UK%7Cf5eaf46dd17f464bb4da08d5f80212f4%7Cb688362589414342b0e37b8cc8392f64%7C1&amp;sdata=7ClOHILllHxyctwFuO9EhPkgKnd2D3nAIEp9S6HFoYo%3D&amp;reserved=0
The contents of this e-mail are confidential and may be subject to legal privilege.
If you are not the intended recipient you must not use, disseminate, distribute or reproduce all or any part of this e-mail or attachments. If you have received this e-mail in error, please notify the sender and delete all material pertaining to this e-mail. Any opinion or views expressed in this e-mail are those of the individual sender and may not represent those of The New Zealand Institute for Plant and Food Research Limited.

########################################################################

To unsubscribe from the GENSTAT list, click the following link:
https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.jiscmail.ac.uk%2Fcgi-bin%2Fwebadmin%3FSUBED1%3DGENSTAT%26A%3D1&amp;data=01%7C01%7Crodger.white%40ROTHAMSTED.AC.UK%7Cf5eaf46dd17f464bb4da08d5f80212f4%7Cb688362589414342b0e37b8cc8392f64%7C1&amp;sdata=7ClOHILllHxyctwFuO9EhPkgKnd2D3nAIEp9S6HFoYo%3D&amp;reserved=0

Rothamsted Research is a company limited by guarantee, registered in England at Harpenden, Hertfordshire, AL5 2JQ under the registration number 2393175 and a not for profit charity number 802038.

########################################################################

To unsubscribe from the GENSTAT list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/webadmin?SUBED1=GENSTAT&A=1

Post generated using Mail2Forum (http://www.mail2forum.com)

Display posts from previous:  

All times are GMT
Page 1 of 1
Post new topic

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum