Re: [R] factor analysis

2007-06-06 Thread Spencer Graves
  I haven't seen an answer to this post, so I thought I would try to 
generate a response. 

  Regarding your first question (Can i use this factor analysis 
somehow despite the poor cumulative variance of the first three factors 
?), I would ask, "for what purpose?"  And, "What are the alternatives?" 

  The second question on the null hypothesis can be answered by 
looking at the degrees of freedom:  That will often identify the null 
hypothesis for a test with a chi-square statistic.  Let p = number of 
original variables, which I assume is 10 in your case as you list 10 
eigenvalues.  Let f = number of factors = 3 in your case.  The degrees 
of freedom is the number of free parameters estimated in a model.  With 
two nested models, the degrees of freedom is the difference in the 
numbers of parameters estimated in the two models. 

  I can think of several obvious hypotheses, in this case:  The two 
extremes are that there are no significant correlations and that a 
saturated model is required.  The former requires no parameters to 
estimate the correlation matrix, while the latter requires choose(p, 2) 
= 45 with p = 10.  To estimate a model with only one factor requires p 
parameters, one for the eigenvalue and (p-1) for the eigenvector / 
direction / factor loadings.  (The sums of squares of the elements of 
each eigenvector = 1.  The factor loadings = the eigenvector times the 
square root of the corresponding eigenvalue.)  Thus, the free parameters 
for a one-factor model = 10.  If this hypothesis compared one factor to 
none, the degrees of freedom would be 10 - 0 = 10.  Similarly, if the 
null hypothesis were saturated, the degrees of freedom would be 45 - 10 
= 35. 

  Next consider a 2-factor model.  In addition to the p coefficients 
estimated for one factor, we must estimate an additional p-1, one 
eigenvalue and p-2 for a unit vector orthogonal to the one we already 
have.  This is 19 degrees of freedom.  Similarly for a 3-factor model, 
we must estimate an additional p-2 parameter, one eigenvalue plus p-3 
for a unit vector orthogonal to the two we already have.  This gives us 
19 + 8 = 27.  Finally a 4-factor model would require estimating p-3 
additional parameters for a total of 34. 

  Now compare the degrees of freedom for the 3-factor model with all 
the others just listed to find one where the difference is the number 
you got, 18.  If we do this we find that 45 - 27 = 18.  From this, we 
conclude that the null hypothesis is the saturated model, i.e., no 
factor structure identifiable from these data. 

  As a check, let's look at your 4-factor model:  45 - 34 = 11.  
This says that your 4-factor model is NOT significantly different from a 
saturated model, i.e., it is adequate.  Returning to the 3-factor model, 
the low p-value in that case says that 3 factors is not enough:  4 
factors provides a more accurate representation. 

  Does this make sense? 

  Note, however, that the above assumes your observations are all 
statistically independent.  If that's not the case, then the assumptions 
behind this test are not satisfied.  Similarly, if the observations are 
not normally distributed, you can't trust this test.  I often check 
normality using 'qqnorm'.  However, if your observations were collected 
in batches, for example, then I would not expect them to be independent. 

  Finally, even though this analysis suggest that a 4-factor model 
is better, I might still use the 3-factor model if it gave me something 
I could interpret and the 4-factor model didn't. 

  Hope this helps. 
  Spencer Graves
p.s.  I might have answered this a day or two earlier, but the lack of a 
simple, self-contained example meant that I would have to work harder to 
understand your question and craft an answer.  

bunny , lautloscrew.com wrote:
> Hi there,
>
> i´ve trouble understanding the factanal output of R.
> i am running a a FA on a dataset with 10 variables.
>
> i plotted eigenvalues to finde out how many factors to try.
> i think the "elbow" is @ 3 factors.
> here are my eigenvalues: 2.6372766 1.5137754 1.0188919 0.8986154  
> 0.8327583 0.7187473 0.6932792 0.5807489 0.5709594 0.5349477
> (of the correlation matrix)
>
> i guess this is basically what screeplot does as well.
>
> and here´s my problem:
> unfortunately the cumulative variance @ 3 factors is only .357
> there are no crossloadings and the interpretation of the factors and  
> their loadings definetely make sense so far.
>
> Can i use this factor analysis somehow despite the poor cumulative  
> variance of the first three factors ?
> changing the rotation didnt help much.
>
> The test of the hypothesis says the following:
>
> Test of the hypothesis that 3 factors are sufficient.
> The chi square statistic is 46.58 on 18 degrees of freedom.
> The p-value is 0.000244
>
> does this mean the Hnull is that 3 factors are sufficient and i cant  
> recject ?
>
>
> 4 factors say:
> Test of t

[R] factor analysis

2007-06-03 Thread bunny , lautloscrew.com
Hi there,

i´ve trouble understanding the factanal output of R.
i am running a a FA on a dataset with 10 variables.

i plotted eigenvalues to finde out how many factors to try.
i think the "elbow" is @ 3 factors.
here are my eigenvalues: 2.6372766 1.5137754 1.0188919 0.8986154  
0.8327583 0.7187473 0.6932792 0.5807489 0.5709594 0.5349477
(of the correlation matrix)

i guess this is basically what screeplot does as well.

and here´s my problem:
unfortunately the cumulative variance @ 3 factors is only .357
there are no crossloadings and the interpretation of the factors and  
their loadings definetely make sense so far.

Can i use this factor analysis somehow despite the poor cumulative  
variance of the first three factors ?
changing the rotation didnt help much.

The test of the hypothesis says the following:

Test of the hypothesis that 3 factors are sufficient.
The chi square statistic is 46.58 on 18 degrees of freedom.
The p-value is 0.000244

does this mean the Hnull is that 3 factors are sufficient and i cant  
recject ?


4 factors say:
Test of the hypothesis that 4 factors are sufficient.
The chi square statistic is 10.82 on 11 degrees of freedom.
The p-value is 0.458

Unfortunately ?factanal does not tell me what the Hnull is in this  
case ?

Thx a lot in advance for some advice

matthias

__
R-help@stat.math.ethz.ch 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.


Re: [R] Factor analysis

2007-06-01 Thread ronggui
I wrote some rough functions for principal factor,
principal-components factor, and  iterated principal factor analysis.
I think they are workable, the same results as stata can be retained.

In addition, functions for gls and uls factor analysis is in progress,
which is based on the algorithms of SPSS. I get the same results by
the gls factor analysis, and quite similiar result by the uls factor
analysis.

2007/6/1, Sigbert Klinke <[EMAIL PROTECTED]>:
> Hi,
>
> is there any other routine for factor analysis in R then factanal?
> Basically I'am interested in another extraction method then the maximum
> likelihood method and looking for unweighted least squares.
>
> Thanks in advance
>
>   Sigbert Klinke
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
Ronggui Huang
Department of Sociology
Fudan University, Shanghai, China

__
R-help@stat.math.ethz.ch 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.


[R] Factor analysis

2007-05-31 Thread Sigbert Klinke
Hi,

is there any other routine for factor analysis in R then factanal? 
Basically I'am interested in another extraction method then the maximum 
likelihood method and looking for unweighted least squares.

Thanks in advance

  Sigbert Klinke

__
R-help@stat.math.ethz.ch 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.


[R] factor analysis and pattern matrix

2007-03-05 Thread Steven Lacey
Hi, 

In a discussion of factor analysis in "Using Multivariate Statistics" by
Tabachnick and Fidell, two matrices are singled out as important for
interpreting an exploratory factor analysis (EFA) with an oblique promax
rotation. One is the "structure matrix". The structure matrix contains the
correlations between variables and factors. However, these correlations may
be inflated because some of the variance in a factor may not be unique to
it. To address this and facilitate the interpretation of factors, the
"pattern matrix" can be calculated as it contains the unique correlations
between variables and factors (that is, the variance shared among factors
has been removed). 

Are the loadings returned from factanal() with a promax rotation the
structure or the pattern matrix? How do I calculate which ever one of the
matrices is not returned by factanal?

Thanks,

Steve

__
R-help@stat.math.ethz.ch 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.


[R] factor analysis and pattern matrix

2007-03-04 Thread Steven Lacey
Hi, 

 

In a discussion of factor analysis in "Using Multivariate Statistics" by
Tabachnick and Fidell, two matrices are singled out as important for
interpreting an exploratory factor analysis (EFA) with an oblique promax
rotation. One is the "structure matrix". The structure matrix contains the
correlations between variables and factors. However, these correlations may
be inflated because some of the variance in a factor may not be unique to
it. To address this and facilitate the interpretation of factors, the
"pattern matrix" can be calculated as it contains the unique correlations
between variables and factors (that is, the variance shared among factors
has been removed). 

 

Are the loadings returned from factanal() with a promax rotation the
structure or the pattern matrix? How do I calculate which ever one of the
matrices is not returned by factanal?

 

Thanks,

Steve


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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.


Re: [R] factor analysis using Principal Component Method

2006-11-28 Thread Peter Dalgaard
Mario Alfonso Morales Rivera wrote:
> Is there any R function to perform factor analysis using Principal
> Component Method?
>
> why factanal() method  is " always "mle" " ?
>   
Because PCM is not "factor analysis" (the two methods fit different
models) and R didn't want to take part in the mislabeling (which I
believe comes from SPSS). You can do  PCM with the prcomp() and
princomp() functions.

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@stat.math.ethz.ch 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.


Re: [R] factor analysis using Principal Component Method

2006-11-28 Thread Patrick Burns
The 'factor.model.stat' function that is available in
the public domain area of the Burns Statistics website
may or may not satisfy your needs.


Patrick Burns
[EMAIL PROTECTED]
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")

Mario Alfonso Morales Rivera wrote:

>Is there any R function to perform factor analysis using Principal
>Component Method?
>
>why factanal() method  is " always "mle" " ?
>
>__
>R-help@stat.math.ethz.ch 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.
>
>
>  
>

__
R-help@stat.math.ethz.ch 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.


[R] factor analysis using Principal Component Method

2006-11-28 Thread Mario Alfonso Morales Rivera
Is there any R function to perform factor analysis using Principal
Component Method?

why factanal() method  is " always "mle" " ?

__
R-help@stat.math.ethz.ch 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.


Re: [R] factor analysis - discrepancy in results from R vs. Stata

2006-05-19 Thread Prof Brian Ripley
I don't believe promax is uniquely defined.  Not only are there 
differences in the criterion (R allows a choice), it is an optimization 
problem with multiple local optima.

In fact the same is true of factanal, and the first thing to check would 
be to see if the same FA solution has been found.

On Fri, 19 May 2006, Ricardo Pietrobon wrote:

> Hi,
>
> I found a discrepancy between results in R and Stata for a factor analysis
> with a promax rotation.  For Stata:

[...]

> This is just one example -- all other comparisons with a different number of
> factors, with and without rotation, generated different numbers.  Any
> thoughts from the list members on the reasons for the discrepancy?
>
> thanks,
>
>
> Ricardo Pietrobon, MD, PhD
> Duke University Health System
>
>   [[alternative HTML version deleted]]

PLEASE don't send HTML code but properly formatted ASCII text.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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, UKFax:  +44 1865 272595

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] factor analysis - discrepancy in results from R vs. Stata

2006-05-19 Thread Ricardo Pietrobon
Hi,

I found a discrepancy between results in R and Stata for a factor analysis
with a promax rotation.  For Stata:

. *rotate, factor(2) promax*



(promax rotation)

   Rotated Factor Loadings

Variable |  1  2Uniqueness

-+

pfq_amanag~y |  -0.178020.641610.70698

pfq_bwalk_~ø |   0.725690.055700.41706

pfq_cwalk_~s |   0.78938   -0.034970.41200

pfq_dkneel~g |   0.80165   -0.041880.39979

pfq_elifting |   0.587000.193960.46795

pfq_fhouse~e |   0.500860.387700.34323

  pfq_gmeals |   0.035160.758840.38781

pfq_hwalki~s |   0.159420.527660.58543

pfq_istand~r |   0.465160.290580.52127

pfq_jget_i~d |   0.318190.433450.52934

   pfq_kfork |   0.024580.487970.74549

pfq_ldress~g |   0.111930.639870.48377

pfq_mstand~s |   0.731770.078170.38311

pfq_nsitti~g |   0.495350.169430.61545

pfq_oreach~d |   0.349800.271560.67887

pfq_pgrasp~l |   0.269750.217780.80248

pfq_qgo_mo~s |   0.257530.652960.28598

pfq_rsocia~t |   0.144820.723480.31770

pfq_sleisu~e |  -0.063160.698220.56654

For R:

*factanal(x = matrix, factors = 2, rotation = "promax")*



Loadings:

 Factor1 Factor2

pfq_amanage_money 0.769

pfq_bwalk_mileø   0.925

pfq_cwalk_steps   0.977

pfq_dkneeling 0.802   0.152

pfq_elifting  0.812   0.114

pfq_fhouse_chore  0.884

pfq_gmeals0.920

pfq_hwalking_rooms0.963

pfq_istand_chair  0.927

pfq_jget_in_out_bed   0.951

pfq_kfork 0.846

pfq_ldressing 0.947

pfq_mstanding_hours   0.844

pfq_nsitting_long 0.795

pfq_oreach_over_head  0.856

pfq_pgrasp_small  0.814

pfq_qgo_movies0.971

pfq_rsocial_event 0.930

pfq_sleisure_home 0.811

This is just one example -- all other comparisons with a different number of
factors, with and without rotation, generated different numbers.  Any
thoughts from the list members on the reasons for the discrepancy?

thanks,


Ricardo Pietrobon, MD, PhD
Duke University Health System

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Re: [R] factor analysis backwards

2006-04-12 Thread Chuck Cleland
Stefan Premke wrote:
> Hello!
> How can I do a factor analysis backwards to get an arbitrary covarianz 
> matrix out of an arbitrary number of generated random variables that 
> have a correlation near zero. Or the same question shorter: How to 
> generate random variables that have a spezial correlation pattern.
> I would like to be able to do this to generate arbitrary data structures 
> for simulation purpose

I'm not sure what you mean by "arbitrary", but have a look at mvrnorm() 
in packages MASS.  For example:

library(MASS)
cor(mvrnorm(n = 300, mu=rep(0,4), Sigma=diag(4)))

 [,1][,2][,3][,4]
[1,]  1. -0.00524425 -0.04464669 -0.01223580
[2,] -0.00524425  1. -0.08920532 -0.10521937
[3,] -0.04464669 -0.08920532  1. -0.05316380
[4,] -0.01223580 -0.10521937 -0.05316380  1.

> sincerely
> stefan
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] factor analysis backwards

2006-04-12 Thread Berton Gunter
RSiteSearch("simulate specified covariance") will bring you to mvrnorm() in
MASS. Please try to use R's built-in search capabilities first before
posting. I realize that keywords can be hard to guess, but you may find that
when the hits are **not** what you want, you need to refine your question
more, as described in the posting guide (have you read it?)

-- Bert Gunter   

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Stefan Premke
Sent: Wednesday, April 12, 2006 6:52 AM
To: r-help@stat.math.ethz.ch
Subject: [R] factor analysis backwards

Hello!
How can I do a factor analysis backwards to get an arbitrary covarianz 
matrix out of an arbitrary number of generated random variables that 
have a correlation near zero. Or the same question shorter: How to 
generate random variables that have a spezial correlation pattern.
I would like to be able to do this to generate arbitrary data structures 
for simulation purpose

sincerely
stefan

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] factor analysis backwards

2006-04-12 Thread Stefan Premke
Hello!
How can I do a factor analysis backwards to get an arbitrary covarianz 
matrix out of an arbitrary number of generated random variables that 
have a correlation near zero. Or the same question shorter: How to 
generate random variables that have a spezial correlation pattern.
I would like to be able to do this to generate arbitrary data structures 
for simulation purpose

sincerely
stefan

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Factor Analysis

2006-01-27 Thread Prof Brian Ripley
On Fri, 27 Jan 2006, Krish Krishnan wrote:

> I am very new to factor analysis as well as R.  I am trying to run a 
> factor analysis on the residual returns on common stock (residual to 
> some model) and trying to determine if there are any strong factors 
> remaining.  After running factanal, I can obtain the factor loadings but 
> how do I get the values of the factor returns themselves?  In other 
> words if the relationship is
>
> r = lambda * f
>
> I prrovide r, factanal estimates the lambdas (factor loadings).  But how do I 
> get the
> f values? Am I looking at this too much from a multivariate regression angle?

Please consult the help page.  The model has an error term.  I don't know
what you mean by 'r': are these correlations or 'x'?

I think you are asking for the scores, which factanal optionally provides.

It is not clear from your description if PCA would not be more 
appropriate.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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, UKFax:  +44 1865 272595

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Factor Analysis

2006-01-27 Thread Krish Krishnan
 I am very new to factor analysis as well as R.  I am trying to run a factor 
analysis on the residual returns on common stock (residual to some model) and 
trying to determine if there are any strong factors remaining.  After running 
factanal, I can obtain the factor loadings but how do I get the values of the 
factor returns themselves?  In other words if the relationship is

r = lambda * f 

I prrovide r, factanal estimates the lambdas (factor loadings).  But how do I 
get the
f values? Am I looking at this too much from a multivariate regression angle?

Thanks



-
 

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Factor Analysis functions...

2005-04-22 Thread Pierre BADY
hi all,

In the library ‘ade4’, there are two eigenanalysis which enable the ordination
of the categorical variables.

1- Multiple Correspondence Analysis (MCA, Tenenhaus & Young 1985) performs the
multiple correspondence analysis of a factor table (see the
function ‘dudi.acm’). this function is equivalent to functions mca of the 
library(MASS)

2- the “mixed factorial analysis” (Hill & Smith 1976) enables the ordination
of tables mixing quantitative variables and factors (functions ‘dudi.mix’
or ‘dudi.hillsmith’).


I hope this helps,

P.BADY




At 15:47 21/04/2005 -0500, Chris Bergstresser wrote:
>Hi all --
>
> I'm running a Factor Analysis on my dataset, and I've located the 
> "factanal()" and "princomp()" methods.  I don't want to do a PCA, so it 
> looks like I should use factanal(), but factanal() requires specifying 
> the number of factors you expect from the analysis.
>Are there any packages out there explicitly for Exploratory Factor 
> Analysis that do not require specifying the number of expected factors?
>
>-- Chris
>
>__
>R-help@stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Pierre BADY <°)><
Université Claude Bernard Lyon 1
UMR CNRS 5023, LEHF
bat Alphonse Forel
43 boulevard du 11 novembre 1918
F-69622 VILLEURBANNE CEDEX
FRANCE
TEL : +33 (0)4 72 44 62 34
FAX : +33 (0)4 72 43 28 92
MEL : [EMAIL PROTECTED]
http://limnologie.univ-lyon1.fr
http://pierre.bady.free.fr (in construction)

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Factor Analysis functions...

2005-04-21 Thread Chris Bergstresser
Hi all --
I'm running a Factor Analysis on my dataset, and I've located the 
"factanal()" and "princomp()" methods.  I don't want to do a PCA, so it 
looks like I should use factanal(), but factanal() requires specifying 
the number of factors you expect from the analysis.
   Are there any packages out there explicitly for Exploratory Factor 
Analysis that do not require specifying the number of expected factors?

-- Chris
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Factor Analysis Biplot

2005-04-14 Thread Jari Oksanen
On Fri, 2005-04-15 at 12:49 +1200, Brett Stansfield wrote:
> Dear R
Dear S,

> When I go to do the biplot
> 
> biplot(eurofood.fa$scores, eurofood$loadings)
> Error in 1:p : NA/NaN argument

Potential sources of error (guessing: no sufficient detail given in the
message):

- you ask scores from eurofood.fa and loadings from eurofood: one of
these names may be wrong.
- you did not ask scores in factanal (they are not there as default, but
you have to specify 'scores').

> 
> Loadings:
>   Factor1 Factor2
> RedMeat0.561  -0.112 
> WhiteMeat  0.593  -0.432 
> Eggs   0.839  -0.195 
> Milk   0.679 
> Fish   0.300   0.951 
> Cereals   -0.902  -0.267 
> Starch 0.542   0.253 
> Nuts  -0.760 
> Fr.Veg-0.145   0.325
> 
The cut values are there, but they are not displayed.  To see this, you
may try:

unclass(eurofood$loadings)
print(eurofuud$loadings, cutoff=0)

cheers, J
-- 
Jari Oksanen -- Dept Biology, Univ Oulu, 90014 Oulu, Finland
email [EMAIL PROTECTED], homepage http://cc.oulu.fi/~jarioksa/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Factor Analysis Biplot

2005-04-14 Thread Brett Stansfield
Dear R
When I go to do the biplot

biplot(eurofood.fa$scores, eurofood$loadings)
Error in 1:p : NA/NaN argument

 I think this is because the component loadings don't show values for some
variables

Loadings:
  Factor1 Factor2
RedMeat0.561  -0.112 
WhiteMeat  0.593  -0.432 
Eggs   0.839  -0.195 
Milk   0.679 
Fish   0.300   0.951 
Cereals   -0.902  -0.267 
Starch 0.542   0.253 
Nuts  -0.760 
Fr.Veg-0.145   0.325

So how can I get it to do a biplot? Is there a way for R to recognise
component loadings less than the cut off value??

Brett Stansfield

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Factor Analysis Biplot

2005-04-14 Thread Brett Stansfield
Dear R help

I am having difficulty doing a biplot of the first two factors of a factor
analysis. I presume it is because the values in factor 2 for Milk and NUTS
are not displayed in the component loadings.

Loadings:
  Factor1 Factor2
RedMeat0.561  -0.112 
WhiteMeat  0.593  -0.432 
Eggs   0.839  -0.195 
Milk   0.679 
Fish   0.300   0.951 
Cereals   -0.902  -0.267 
Starch 0.542   0.253 
Nuts  -0.760 
Fr.Veg-0.145   0.325

It has no problem doing a normal plot using
plot(eurofood.fa$scores[,1], eurofood.fa$scores[,2])

But when I ask for a biplot I get

biplot(eurofood.fa$scores[,1], eurofood.fa$scores[,2])
Error in 1:n : NA/NaN argument

What can I do to overcome this??
Brett Stansfield

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Factor analysis with dichotomous variables

2004-12-17 Thread Chris Lawrence
On Fri, 17 Dec 2004 13:07:08 -0500, Doran, Harold <[EMAIL PROTECTED]> wrote:
> You can use factanal to do the analysis. The polychor() package will
> give you polychorics. You can then the do the factor analysis on this
> correlation matrix.
> 
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Tom Denson
> Sent: Friday, December 17, 2004 12:31 PM
> To: [EMAIL PROTECTED]
> Subject: [R] Factor analysis with dichotomous variables
> 
> Hello,
> 
> I would like to conduct an exploratory factor analysis with dichotomous
> data. Do any R routines exist for this purpose? I recall reading
> something about methods with tetrachoric correlations.
> 
> Any help would be appreciated.

You may also want to consider the routines in MCMCpack
(MCMCordfactanal and MCMCmixfactanal), depending on your application.


Chris
-- 
Chris Lawrence - http://blog.lordsutch.com/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] Factor analysis with dichotomous variables

2004-12-17 Thread Doran, Harold
You can use factanal to do the analysis. The polychor() package will
give you polychorics. You can then the do the factor analysis on this
correlation matrix. 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Tom Denson
Sent: Friday, December 17, 2004 12:31 PM
To: [EMAIL PROTECTED]
Subject: [R] Factor analysis with dichotomous variables

Hello,

I would like to conduct an exploratory factor analysis with dichotomous
data. Do any R routines exist for this purpose? I recall reading
something about methods with tetrachoric correlations.

Any help would be appreciated.

Best,
Tom Denson
Department of Psychology
University of Southern California

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Factor analysis with dichotomous variables

2004-12-17 Thread Tom Denson
Hello,

I would like to conduct an exploratory factor analysis with dichotomous
data. Do any R routines exist for this purpose? I recall reading something
about methods with tetrachoric correlations.

Any help would be appreciated.

Best,
Tom Denson
Department of Psychology
University of Southern California

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] factor analysis package

2004-06-15 Thread Prof Brian Ripley
R comes with support for factor analysis and PCA (*not* the same thing)
in package stats which is normally loaded.

Try

help.search("factor analysis")
help.search("principal components")

On Tue, 15 Jun 2004, Katja Loytynoja wrote:

> Hello everyone, is there a package/packages for factor analysis, 
> particularly PCA? 

> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

PLEASE DO.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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, UKFax:  +44 1865 272595

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] factor analysis package

2004-06-15 Thread Peter Dalgaard
Katja Loytynoja <[EMAIL PROTECTED]> writes:

> Hello everyone, is there a package/packages for factor analysis, 
> particularly PCA? 

help.search("factor analysis")
help.search("principal components")

(Whether PCA qualifies as "factor analysis" is debatable, though...)

-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] factor analysis package

2004-06-15 Thread Katja Loytynoja

Hello everyone, is there a package/packages for factor analysis, 
particularly PCA? 

thanks,
Katja 


Katja Löytynoja 
Taitoniekantie 9 A 218
40 740 Jyväskylä 
Finland
tel.+35814 608058
cell.+35850 336 0174 
[EMAIL PROTECTED]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] factor analysis

2004-05-14 Thread Andrew Criswell
Hello:
The website 
http://ourworld.compuserve.com/homepages/jsuebersax/tetra.htm might 
provide you with further hints and information on implementing 
polychoric correlations. Further information related to your inquiry can 
also be found on http://www.unt.edu/rss/class/rich/5840/

In addition, possibly relevant S+ code can be found on 
http://www.biostat.wustl.edu/archives/html/s-news/2001-02/msg00079.html

ANDREW
John Fox wrote:
Dear Allan,
I assume that the categorical data are ordinal. There are methods for
factor analyzing ordinal data (e.g., using polychoric correlations) and
mixed ordinal and interval data, but as far as I know, these aren't
implemented in R.
John
On Thu, 13 May 2004 18:32:11 +0200
allan clark <[EMAIL PROTECTED]> wrote:
 

hi all
this is a stats question.
when undertaking factor analysis should the variables included always
be
continiuos random variables? could one include categorical data? e.g
some survey type data
my gut feeling is that one should not include categorical type data
since factor analysis is based on the eigenanalysis of the
correlation
matrix of a group of variables. The introduction of categorical data
into a data set might "mess up" the corelation matrix.
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
   



John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

 

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] factor analysis

2004-05-13 Thread Pierre BADY
hi all,

In the library ‘ade4’, there are two eigenanalysis which enable the ordination 
of the categorical variables. 

1- Multiple Correspondence Analysis (MCA, Tenenhaus & Young 1985) performs the 
multiple correspondence analysis of a factor table (see the 
function ‘dudi.acm’). 

2- the “mixed factorial analysis” (Hill & Smith 1976)  enables the ordination 
of tables mixing quantitative variables and factors (functions ‘dudi.mix’ 
or  ‘dudi.hillsmith’).


I hope this helps,

P.BADY



En réponse à John Fox <[EMAIL PROTECTED]>:
> Dear Allan,
> 
> I assume that the categorical data are ordinal. There are methods for
> factor analyzing ordinal data (e.g., using polychoric correlations)
> and
> mixed ordinal and interval data, but as far as I know, these aren't
> implemented in R.
> 
> John
> 
> On Thu, 13 May 2004 18:32:11 +0200
>  allan clark <[EMAIL PROTECTED]> wrote:
> > hi all
> > 
> > this is a stats question.
> > 
> > when undertaking factor analysis should the variables included
> always
> > be
> > continiuos random variables? could one include categorical data? e.g
> > some survey type data
> > 
> > my gut feeling is that one should not include categorical type data
> > since factor analysis is based on the eigenanalysis of the
> > correlation
> > matrix of a group of variables. The introduction of categorical data
> > into a data set might "mess up" the corelation matrix.
> > 
> > __
> > [EMAIL PROTECTED] mailing list
> > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> > http://www.R-project.org/posting-guide.html
> 
> 
> 
> John Fox
> Department of Sociology
> McMaster University
> Hamilton, Ontario, Canada
> http://socserv.mcmaster.ca/jfox/
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
> 
> 



-
Pierre BADY 
Université Claude Bernard Lyon 1
UMR CNRS 5023, LEHF
bat Alphonse Forel
43 boulevard du 11 novembre 1918 
F-69622 VILLEURBANNE CEDEX 
FRANCE
TEL : +33 (0)4 72 44 62 34 
FAX : +33 (0)4 72 43 28 92 
MEL : [EMAIL PROTECTED]
http://limnologie.univ-lyon1.fr
http://badgloup.ifrance.com

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] factor analysis

2004-05-13 Thread John Fox
Dear Allan,

I assume that the categorical data are ordinal. There are methods for
factor analyzing ordinal data (e.g., using polychoric correlations) and
mixed ordinal and interval data, but as far as I know, these aren't
implemented in R.

John

On Thu, 13 May 2004 18:32:11 +0200
 allan clark <[EMAIL PROTECTED]> wrote:
> hi all
> 
> this is a stats question.
> 
> when undertaking factor analysis should the variables included always
> be
> continiuos random variables? could one include categorical data? e.g
> some survey type data
> 
> my gut feeling is that one should not include categorical type data
> since factor analysis is based on the eigenanalysis of the
> correlation
> matrix of a group of variables. The introduction of categorical data
> into a data set might "mess up" the corelation matrix.
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html



John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Factor Analysis

2003-02-27 Thread Spencer Graves
Of course.  Thanks for the correction.  Spencer Graves

[EMAIL PROTECTED] wrote:
On Thu, 27 Feb 2003, Spencer Graves wrote:


To obtain an nonsingular estimate of an (n x n) covariance or 
correlation matrix, you need at least (n+1) observations.  However, you 
can obtain estimates of the largest k singular values or eigenvalues 
with only (k+1) observations.  The principal components routine must use 
something like "eigen" or "svd", which does not require a nonsingular 
covariance matrix.


That's because principal components analysis is defined for simgular 
covariance matrices, but the factor analysis model can never generate 
them.  It's not to do with the computational technique.

Using PCA to find constant combinations is quite common, and such data 
matrices have singular covariance structures.


[EMAIL PROTECTED] wrote:

I am encountering a problem while doing factor analysis in R. I am using
correlation matrix of the performance data of funds.And it gives me error
message saying singular matrix in use. Now when I try to find the
determinant of this matrix it is indeed singular. The problem is when I use
same matrix for principal component analysis it works. I was wondering if
any of you could help me with this.


__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Factor Analysis

2003-02-27 Thread ripley
On Thu, 27 Feb 2003, Spencer Graves wrote:

> To obtain an nonsingular estimate of an (n x n) covariance or 
> correlation matrix, you need at least (n+1) observations.  However, you 
> can obtain estimates of the largest k singular values or eigenvalues 
> with only (k+1) observations.  The principal components routine must use 
> something like "eigen" or "svd", which does not require a nonsingular 
> covariance matrix.

That's because principal components analysis is defined for simgular 
covariance matrices, but the factor analysis model can never generate 
them.  It's not to do with the computational technique.

Using PCA to find constant combinations is quite common, and such data 
matrices have singular covariance structures.

> [EMAIL PROTECTED] wrote:
> > 
> > I am encountering a problem while doing factor analysis in R. I am using
> > correlation matrix of the performance data of funds.And it gives me error
> > message saying singular matrix in use. Now when I try to find the
> > determinant of this matrix it is indeed singular. The problem is when I use
> > same matrix for principal component analysis it works. I was wondering if
> > any of you could help me with this.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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, UKFax:  +44 1865 272595

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Factor Analysis

2003-02-27 Thread Spencer Graves
To obtain an nonsingular estimate of an (n x n) covariance or 
correlation matrix, you need at least (n+1) observations.  However, you 
can obtain estimates of the largest k singular values or eigenvalues 
with only (k+1) observations.  The principal components routine must use 
something like "eigen" or "svd", which does not require a nonsingular 
covariance matrix.

Spencer Graves

[EMAIL PROTECTED] wrote:
Hello,

I am encountering a problem while doing factor analysis in R. I am using
correlation matrix of the performance data of funds.And it gives me error
message saying singular matrix in use. Now when I try to find the
determinant of this matrix it is indeed singular. The problem is when I use
same matrix for principal component analysis it works. I was wondering if
any of you could help me with this.
Rahul Maniar

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help
__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Factor Analysis

2003-02-27 Thread rahul . maniar
Hello,

I am encountering a problem while doing factor analysis in R. I am using
correlation matrix of the performance data of funds.And it gives me error
message saying singular matrix in use. Now when I try to find the
determinant of this matrix it is indeed singular. The problem is when I use
same matrix for principal component analysis it works. I was wondering if
any of you could help me with this.

Rahul Maniar

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] factor analysis (pca): how to get the 'communal

2003-01-04 Thread bmagill
On 4 Jan 2003 at 12:51, Wolfgang Lindner wrote:


> Please excuse me, if the following questions are *too* off-topic, but I found it 
> interesting. In inspecting your code I came across an R feature, I could not 
> find in the online manuals:
> 
> Q1. Looking at the left-handside in your function def:
> 
> "cov.cor" <- function ( covmat ) {
> sdev <- diag ( sqrt ( diag ( covmat ) ) ) 
> solve(sdev) %*% covmat %*% t(solve(sdev))  }
> ^   ^
> |   |
> ?   ?
> 
> - *Why* is the (identifier) function name cov.cor included in question marks? 
> - How is "cov.cor" then called?  "cov.cor"(..) or cov.cor(..) or ?

The quotation marks are the result of using dump() to write the set of functions to a 
file.  As was pointed out, it is not necessary to use quotation marks when calling any 
of these  functions.

As far as documentation, I simply have not done it yet.  In the meantime, if you have 
specific questions about how to use some of the functions, I can provide some 
examples and some on the fly documentation, let me know, specifically, what you 
want to use/know.  That, we should probably take off-list however.

In generall, you can source() the .R file in.  After doing that the entire set of 
functions 
will be available in your workspace for you to see using ls() and examine by calling 
the function name.

Regards, Brett










--- End of forwarded message ---

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help



Re: [R] factor analysis (pca): how to get the 'communalities'?

2003-01-04 Thread bmagill
On 4 Jan 2003 at 12:51, Wolfgang Lindner wrote:


> Please excuse me, if the following questions are *too* off-topic, but I found it 
> interesting. In inspecting your code I came across an R feature, I could not 
> find in the online manuals:
> 
> Q1. Looking at the left-handside in your function def:
> 
> "cov.cor" <- function ( covmat ) {
> sdev <- diag ( sqrt ( diag ( covmat ) ) ) 
> solve(sdev) %*% covmat %*% t(solve(sdev))  }
> ^   ^
> |   |
> ?   ?
> 
> - *Why* is the (identifier) function name cov.cor included in question marks? 
> - How is "cov.cor" then called?  "cov.cor"(..) or cov.cor(..) or ?

The quotation marks are the result of using dump() to write the set of functions to a 
file.  As was pointed out, it is not necessary to use quotation marks when calling any 
of these  functions.

As far as documentation, I simply have not done it yet.  In the meantime, if you have 
specific questions about how to use some of the functions, I can provide some 
examples and some on the fly documentation, let me know, specifically, what you 
want to use/know.  That, we should probably take off-list however.

In generall, you can source() the .R file in.  After doing that the entire set of 
functions 
will be available in your workspace for you to see using ls() and examine by calling 
the function name.

Regards, Brett

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help



Re: [R] factor analysis (pca): how to get the 'communalities'?

2003-01-04 Thread Uwe Ligges
Wolfgang Lindner wrote:
> 
> Brett Magill schrieb:
> | If interested, on my web site I have code to do factor analysis by PC.  Does
> | exactly as below, but a nice wrapper to print methods, rotations, sorting, and
> | other conveniences.
> |
> |   home.earthlink.net/~bmagill/MyMisc.html
> |
> | The relevant code snipets are "prinfact", "plot.pfa", and "print.pfa", along
> | with the other required functions as indiciated on the web site.
> 
> Dear Brett,
> 
> thanks very much for supplying your code. It's really illuminating.
> Now, let me quote you
>  'When I have time, I will document them and wrap them up into a package that
>   can be installed.'
> I hope you will find some time to prepare 'Your'Misc-1.0.R ;-) ..
> Helpful could be to give some examples of calling your functions.
> 
> Please excuse me, if the following questions are *too* off-topic, but I found it
> interesting. In inspecting your code I came across an R feature, I could not
> find in the online manuals:
> 
> Q1. Looking at the left-handside in your function def:
> 
> "cov.cor" <- function ( covmat ) {
> sdev <- diag ( sqrt ( diag ( covmat ) ) )
> solve(sdev) %*% covmat %*% t(solve(sdev))  }
> ^   ^
> |   |
> ?   ?
> 
> - *Why* is the (identifier) function name cov.cor included in question marks?

It's not necessary for this particular name to put in in quotes, but you
can put any name in quotes:

 "x" <- 5
 x

Here you must quote (BAD idea to choose such names!, NOT
recommended!!!):
 "x 1" <- 5
 get("x 1")


> - How is "cov.cor" then called?  "cov.cor"(..) or cov.cor(..) or ?

Both ways are possible in this case.


> Q2. Please, can someone give me a pointer where this feature is described.

R FAQ 7.16 - 2. item in the enumeration.

 
> Finally I want to thank the list for this thread.

Uwe Ligges

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help



Re: [R] factor analysis (pca): how to get the 'communalities'?

2003-01-04 Thread Wolfgang Lindner
Brett Magill schrieb:
| If interested, on my web site I have code to do factor analysis by PC.  Does
| exactly as below, but a nice wrapper to print methods, rotations, sorting, and
| other conveniences.
|
|   home.earthlink.net/~bmagill/MyMisc.html 
|
| The relevant code snipets are "prinfact", "plot.pfa", and "print.pfa", along
| with the other required functions as indiciated on the web site.

Dear Brett,

thanks very much for supplying your code. It's really illuminating.
Now, let me quote you
 'When I have time, I will document them and wrap them up into a package that
  can be installed.'
I hope you will find some time to prepare 'Your'Misc-1.0.R ;-) ..
Helpful could be to give some examples of calling your functions. 

Please excuse me, if the following questions are *too* off-topic, but I found it 
interesting. In inspecting your code I came across an R feature, I could not 
find in the online manuals:

Q1. Looking at the left-handside in your function def:

"cov.cor" <- function ( covmat ) {
sdev <- diag ( sqrt ( diag ( covmat ) ) ) 
solve(sdev) %*% covmat %*% t(solve(sdev))  }
^   ^
|   |
?   ?

- *Why* is the (identifier) function name cov.cor included in question marks? 
- How is "cov.cor" then called?  "cov.cor"(..) or cov.cor(..) or ?

Q2. Please, can someone give me a pointer where this feature is described.

Finally I want to thank the list for this thread.

Wolfgang
--
Wolfgang Lindner   [EMAIL PROTECTED]
   Gerhard-Mercator-Universitaet Duisburg  Tel: +49 0203 379-1326
   Fakultaet 4 - Naturwissenschaften   Fax: +49 0203 379-2528
   Institut fuer Mathematik,  LE 424
   Lotharstr. 65
   D 47048  Duisburg (Germany)

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help



Re: [R] factor analysis (pca): how to get the 'communalities'?

2003-01-03 Thread Brett Magill
If interested, on my web site I have code to do factor analysis by PC.  Does
exactly as below, but a nice wrapper to print methods, rotations, sorting, and
other conveniences.

  home.earthlink.net/~bmagill/MyMisc.html 

The relevant code snipets are "prinfact", "plot.pfa", and "print.pfa", along
with the other required functions as indiciated on the web site.


On Fri, 3 Jan 2003 21:04:21 +0100 Wolfgang Lindner <[EMAIL PROTECTED]>
wrote:

> Scot,
> 
> thank you very much for your wonderful clear
> and short fix of my first problem: 
> seeing your solution as one-liner in the
> impressive insightful syntax of R is 
> really an aesthetic experience for me:
> 
> |  I ran your example and found that you can
> get the eigenvalues SPSS by [..]
> |m.pca$sdev^2
> |  So squaring the standard deviations (sdev)
> of the components gives you the
> |  eigenvalues SPSS reports.
> 
> I am a little sorrow of not having seen it for
> myself ;-) - but I think that's 
> live in becoming a friend of R and making the
> first steps with pca, fa, ca & co. 
> R is indeed a first choice tool in doing
> understandable statistics and Prof 
> Ripley's indication to R's open code points
> definitive in the same direction for 
> me. Now the two worlds become reconciled and
> the fog gets thinner for me.
> Thank you both.
> 
> Wolfgang
> --
> Wolfgang Lindner  
> [EMAIL PROTECTED]
>Gerhard-Mercator-Universitaet Duisburg  Tel:
> +49 0203 379-1326
> 
> __
> [EMAIL PROTECTED] mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help
>

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help



Re: [R] factor analysis (pca): how to get the 'communalities'?

2003-01-03 Thread Wolfgang Lindner
Scot,

thank you very much for your wonderful clear and short fix of my first problem: 
seeing your solution as one-liner in the impressive insightful syntax of R is 
really an aesthetic experience for me:

|  I ran your example and found that you can get the eigenvalues SPSS by [..]
|m.pca$sdev^2
|  So squaring the standard deviations (sdev) of the components gives you the
|  eigenvalues SPSS reports.

I am a little sorrow of not having seen it for myself ;-) - but I think that's 
live in becoming a friend of R and making the first steps with pca, fa, ca & co. 
R is indeed a first choice tool in doing understandable statistics and Prof 
Ripley's indication to R's open code points definitive in the same direction for 
me. Now the two worlds become reconciled and the fog gets thinner for me.
Thank you both.

Wolfgang
--
Wolfgang Lindner   [EMAIL PROTECTED]
   Gerhard-Mercator-Universitaet Duisburg  Tel: +49 0203 379-1326

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help



Re: [R] factor analysis (pca): how to get the 'communalities'?

2003-01-03 Thread Wolfgang Lindner
Dear Prof. Ripley,

many thanks for your prompt answer and the valuable hints and pointers, I will 
study them and try it again.

1.
Sorry, for not giving the full quote; my book is:

Venables & Ripley: MASS. Springer 1999, 3rd Ed. (Corr. 3rd printing 2001); 
   § 11.1, p. 330 ff.   (§11 written by B.D.R.)

> Those editions which cover factor analysis do explain the difference.
So I will look for the latest edition ..

2.
> 3) Don't believe SPSS knows what it is doing.
o.k. I see ;-) 

Best regards
Wolfgang

--
Wolfgang Lindner   [EMAIL PROTECTED]
   Gerhard-Mercator-Universitaet Duisburg  Tel: +49 0203 379-1326
   Fakultaet 4 - Naturwissenschaften   Fax: +49 0203 379-2528
   Institut fuer Mathematik,  LE 424
   Lotharstr. 65
   D 47048  Duisburg (Germany)

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help



Re: [R] factor analysis (pca): how to get the 'communalities'?

2003-01-03 Thread ripley
On Fri, 3 Jan 2003, Wolfgang Lindner wrote:

> I try some test data for a factorAnalysis (resp. pca) in the sense of Prof.

Well, factor analysis and pca are different things, and only one
is appropriate in a given problem.

> Ripley's MASS § 11.1, p. 330 ff.,

Eh?  Would that be *Venables & Ripley's* MASS, and if so which edition (it
is not the current one).  Those editions which cover factor analysis do
explain the difference.

>just to prepare myself for an analysis of my
> own empirical data using R (instead of SPSS).
>
> 1. the data.
>
> ## The test data is (from the book of Backhaus et al.: Multivariate ##
> Analysemethoden. Springer 2000 [9th ed.], p. 300 ff):
>
> a<-c(4.5,5.167,5.059,3.8,3.444,3.5,5.25,5.857,5.083,5.273,4.5)
> b<-c(4.0,4.25,3.824,5.4,5.056,3.5,3.417,4.429,4.083,3.6,4.0)
> c<-c(4.375,3.833,4.765,3.8,3.778,3.875,4.583,4.929,4.667,3.909,4.2)
> d<-c(3.875,3.833,3.438,2.4,3.765,4.0,3.917,3.857,4.0,4.091,3.9)
> e<-c(3.25,2.167,4.235,5.0,3.944,4.625,4.333,4.071,4.0,4.091,3.7)
> f<-c(3.75,3.75,4.471,5.0,5.389,5.250,4.417,5.071,4.25,4.091,3.9)
> g<-c(4.0,3.273,3.765,5.0,5.056,5.5,4.667,2.929,3.818,4.545,3.6)
> h<-c(2.0,1.857,1.923,4.0,5.615,6.0,3.25,2.091,1.545,1.6,1.5)
> i<-c(4.625,3.75,3.529,4.0,4.222,4.75,4.5,4.571,3.75,3.909,3.5)
> j<-c(4.125,3.417,3.529,4.6,5.278,5.375,3.583,3.786,4.167,3.818,3.7)
>
> m<-data.frame(a,b,c,d,e,f,g,h,i,j)
>
> 2. My try of a pca with R.
>
> ## My R input was:
>
> m
> cor(m)
> library(mva)
> m.pca<-princomp(m,cor=T)
> m.pca
> summary(m.pca)
> loadings(m.pca)
> m.pca$scores
> m.FA <- factanal(factors = 3, covmat=cov(m))
> m.FA
>
> 3. Here are my questions.
>
> Q1.
> The cor(m)-Matrix is the same as reported by using SPSS (or OpenStats2).
> But in R I get other eigenvalues compared with the following SPSS output:

You don't get eigenvalues at all in R.  You do get `Proportion of
Variance' which are these numbers divided by their total.

> Original matrix trace =  10,00
> Roots (Eigenvalues) Extracted:
>1  5,052
>2  1,771
>3  1,427
>4  0,819
>5  0,430
>6  0,247
>7  0,159
>8  0,062
>9  0,029
>   10  0,003
>
> - What is going behind the scene?

Why don't you ask the SPSS people that?  R at least gives you sensible
labels on the output.

> - Or what I am doing wrong in my use of R?
> - If I am doing the pca correct, can I use the R results as equally aceptable
>   without further discussion?

No, as more acceptable: at least they have meaningful labels.

>   Maybe a different 'hidden' algorithm is the reason for different results?

Ask SPSS that.  R's code is open, and nothing is hidden.  You have not
demonstrated that the results are different, anyway!

> Q2. How to get the so called 'Communality Estimates' with R?

First, use the data as in

> (m.FA <- factanal(m, factors=3))

and where did the number of factors come from?

100*(1 - m.FA$uniquenesses) gives the communalities.  They are different
from SPSS, because (1) R uses maximum likelihood FA and (2) tries a lot
harder to find a maximum and there are many local maxima in most FA
problems.

In this case you have fitted too many factors, and just one suffices.

> Here the values reported by SPSS for the above test data.frame m:
> Communality Estimates as percentages:
>   1 88,619
>   2 76,855
>   3 89,167
>   4 85,324
>   5 76,043
>   6 84,012
>   7 80,223
>   8 92,668
>   9 63,297
>  10 88,786
>
> Any help, suggestions or hints are very welcome.

1) Be a lot more accurate.
2) Read the help pages to find out what the output means.  In the case of
R the information is there, but you may well have to post on an SPSS help
list to find out why SPSS gives different output from R.
3) Don't believe SPSS knows what it is doing.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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, UKFax:  +44 1865 272595

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help



[R] factor analysis (pca): how to get the 'communalities'?

2003-01-02 Thread Wolfgang Lindner
Dear expe-R-ts,

I try some test data for a factorAnalysis (resp. pca) in the sense of Prof. 
Ripley's MASS § 11.1, p. 330 ff., just to prepare myself for an analysis of my 
own empirical data using R (instead of SPSS).

1. the data.

## The test data is (from the book of Backhaus et al.: Multivariate ## 
Analysemethoden. Springer 2000 [9th ed.], p. 300 ff):

a<-c(4.5,5.167,5.059,3.8,3.444,3.5,5.25,5.857,5.083,5.273,4.5)
b<-c(4.0,4.25,3.824,5.4,5.056,3.5,3.417,4.429,4.083,3.6,4.0)
c<-c(4.375,3.833,4.765,3.8,3.778,3.875,4.583,4.929,4.667,3.909,4.2)
d<-c(3.875,3.833,3.438,2.4,3.765,4.0,3.917,3.857,4.0,4.091,3.9)
e<-c(3.25,2.167,4.235,5.0,3.944,4.625,4.333,4.071,4.0,4.091,3.7)
f<-c(3.75,3.75,4.471,5.0,5.389,5.250,4.417,5.071,4.25,4.091,3.9)
g<-c(4.0,3.273,3.765,5.0,5.056,5.5,4.667,2.929,3.818,4.545,3.6)
h<-c(2.0,1.857,1.923,4.0,5.615,6.0,3.25,2.091,1.545,1.6,1.5)
i<-c(4.625,3.75,3.529,4.0,4.222,4.75,4.5,4.571,3.75,3.909,3.5)
j<-c(4.125,3.417,3.529,4.6,5.278,5.375,3.583,3.786,4.167,3.818,3.7)

m<-data.frame(a,b,c,d,e,f,g,h,i,j)

2. My try of a pca with R.

## My R input was:

m
cor(m)
library(mva)
m.pca<-princomp(m,cor=T)
m.pca
summary(m.pca)
loadings(m.pca)
m.pca$scores
m.FA <- factanal(factors = 3, covmat=cov(m))
m.FA

3. Here are my questions. 

Q1. 
The cor(m)-Matrix is the same as reported by using SPSS (or OpenStats2). 
But in R I get other eigenvalues compared with the following SPSS output:

Original matrix trace =  10,00
Roots (Eigenvalues) Extracted:
   1  5,052
   2  1,771
   3  1,427
   4  0,819
   5  0,430
   6  0,247
   7  0,159
   8  0,062
   9  0,029
  10  0,003

- What is going behind the scene? 
- Or what I am doing wrong in my use of R?
- If I am doing the pca correct, can I use the R results as equally aceptable 
  without further discussion? 
  Maybe a different 'hidden' algorithm is the reason for different results?

Q2. How to get the so called 'Communality Estimates' with R?

Here the values reported by SPSS for the above test data.frame m:
Communality Estimates as percentages:
  1 88,619
  2 76,855
  3 89,167
  4 85,324
  5 76,043
  6 84,012
  7 80,223
  8 92,668
  9 63,297
 10 88,786

Any help, suggestions or hints are very welcome.
Best regards and happy new year for you and R

Wolfgang

--
Wolfgang Lindner   [EMAIL PROTECTED]
   Gerhard-Mercator-Universitaet Duisburg  Tel: +49 0203 379-1326
   Fakultaet 4 - Naturwissenschaften   Fax: +49 0203 379-2528
   Institut fuer Mathematik,  LE 424
   Lotharstr. 65
   D 47048  Duisburg (Germany)

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help