[R] How-To construct a cov list to use a covariance matrix in factanal?

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Feb 6 16:04:48 CET 2007


The help page says

   covmat: A covariance matrix, or a covariance list as returned by
           'cov.wt'.  Of course, correlation matrices are covariance
           matrices.

and there is an example of a covariance list (ability.cov).

> factanal(factors = 2, covmat = ability.cov)
> factanal(factors = 2, covmat = ability.cov$cov)

both work.  See

> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

as we have no idea what you tried.

On Tue, 6 Feb 2007, Alistair Campbell wrote:

> Hi,
>
> I have a set of covariance matrices but not the original data. I want to 
> carry out some exploratory factor analysis. So, I am trying to construct 
> a covariance matrix list as the input for factanal. I can construct a 
> list which includes the cov, the centers, and the n.obs. But it doesn't 
> work. I get an error that says "Error in sqrt(diag(cv)) : Non-numeric 
> argument to mathematical function". So, obviously I am doing something 
> wrong.
>
> Two questions occur. Can someone either tell me how to construct a 
> proper covmat list object or point me to a description of how to do it? 
> The other question is whether it is possible to simply use the 
> covariance matrix as the argument for covmat in factanal? The 
> description implies that it is but I really have no idea of how to do 
> this. I have tried simply making covmat the covariance matrix but it 
> doesn't wotk. I just get the message "'covmat' is not a valid covariance 
> list"
>
> Anyway, thanks for any thoughts you might have on this.
>
> Alistair Campbell
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list