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

Alistair Campbell alistair.campbell at jcu.edu.au
Wed Feb 7 02:00:33 CET 2007


Thanks for that Brian,

I have worked through the examples. They work because the covmat were produced by the cov.wt which provides output as a list object. I am trying to construct my own list object to use as the covmat. There are no obvious instructions on how to do this.

So, here is what I have done so far.

I reconstructed the covariance matrix in the example and created a dataframe:

 > testmatrix
  general picture  blocks   maze reading   vocab
1  24.641   5.991  33.520  6.023  20.755  29.701
2   5.991   6.700  18.137  1.782   4.936   7.204
3  33.520  18.137 149.831 19.424  31.430  50.753
4   6.023   1.782  19.424 12.711   4.757   9.075
5  20.755   4.936  31.430  4.757  52.604  66.762
6  29.701   7.204  50.753  9.075  66.762 135.292

and then used this to construct a list object like the output from the example;

> tstcov<- list(cov=testmatrix, center=c(0,0,0,0,0), n.obs=112)

I tested to see whether my list object looked like the examples

> tstcov
$cov
  general picture  blocks   maze reading   vocab
1  24.641   5.991  33.520  6.023  20.755  29.701
2   5.991   6.700  18.137  1.782   4.936   7.204
3  33.520  18.137 149.831 19.424  31.430  50.753
4   6.023   1.782  19.424 12.711   4.757   9.075
5  20.755   4.936  31.430  4.757  52.604  66.762
6  29.701   7.204  50.753  9.075  66.762 135.292

$centers
[1] 0 0 0 0 0

$n.obs
[1] 112

It looks the same. So I then used this list as the argument in factanal and get the error message.

> factanal(factors=2, covmat=tstcov, rotation="varimax")
Error in sqrt(diag(cv)) : Non-numeric argument to mathematical function

I know that what you see of a list is not necessarily all that is there. So, I figure I am missing some part of the object that makes this list suitable for use by factanal.

So, I hope this is enough detail. Any thoughts would be appreciated.
-- 
Dr Alistair Campbell, PhD
Senior Lecturer in Clinical Psychology
School of Psychology
James Cook University
Townsville Queensland Australia

Ph: +61 7 47816879



More information about the R-help mailing list