[R] Basic regression output question

Kingsford Jones kingsfordjones at gmail.com
Mon Mar 23 20:07:23 CET 2009


On Mon, Mar 23, 2009 at 11:04 AM, GRANT Lewis <L.Grant at hermes.co.uk> wrote:

[snip]

> factors<-matrix(runif(400),nrow=40)
> returns1<-matrix(runif(40),nrow=1)
> returns2<-matrix(runif(2000),nrow=50)
> coef(summary(lm(t(returns1)~factors)))[1,4]

[snip]

> (coef(summary(lm(t(returns2)~factors)))[50])[1,4]
>
> Error in `[.default`((coef(summary(lm(t(returns2) ~ factors)))[50]), 1,
> :
>  incorrect number of dimensions


Use of the 'str' function will reveal you are indexing a list element,
so try [[50]] rather than [50]

hth,

Kingsford Jones



>
>
>
> **********************************************************************
> Hermes Fund Managers Limited
> Registered in England No. 1661776, Lloyds Chambers, 1 Portsoken Street, London E1 8HZ
>
> *** Please read the Hermes email disclaimer at http://www.hermes.co.uk/email_terms.htm before acting on this email or opening any attachment ***
>
> The contents of this email are confidential.  If you have received this message in error, please delete it immediately and contact the sender directly or the Hermes IT Helpdesk on +44(0)20 7680 2117.  Any reliance on, use, disclosure, dissemination, distribution or copying of this email is unauthorised and strictly prohibited.
>
> This message has been checked for viruses but the recipient is strongly advised to rescan the message before opening any attachments or attached executable files.  Hermes do not accept any liability for any damage sustained as a result of a virus introduced by this email or any attachment.
>
>
> **********************************************************************
>
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list