Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: AW: AW: PCA results and new variable


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: AW: PCA results and new variable
Date   Thu, 11 Mar 2010 13:46:56 +0100

<> 

Terribly complicated, but it works:


*************


sysuse auto, clear
mata: mata clear

levelsof foreign
gen first=.

foreach lev in `r(levels)'{
	pca trunk weight length headroom if foreign==`lev' 
		mata:ev=st_matrix("e(Ev)")'
		mata: st_numscalar("r(first)", ev[1,1]/sum(ev))
replace first = `r(first)' if foreign==`lev'
}

sort foreign
l foreign first in 40/60
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von
[email protected]
Gesendet: Donnerstag, 11. März 2010 13:07
An: [email protected]
Betreff: st: AW: PCA results and new variable 

Regarding the official example, I would need to make,

*************
sysuse auto, clear
bys foreign: pca trunk weight length headroom

and then create a new variable with the cumulative of the first compenent
of each group (foreign or domestic)assigned to each "car".

Thanks a lot


st: AW: PCA results and new variable

----------------------------------------------------------------------------
----
>From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: PCA results and new variable
Date   Thu, 11 Mar 2010 12:46:46 +0100

----------------------------------------------------------------------------
----

<>

-statsby- could be your friend, but you really need to frame your question
in terms of an official example:


*************
sysuse auto, clear
bys rep78: pca trunk weight length headroom
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von
[email protected]
Gesendet: Donnerstag, 11. März 2010 12:29
An: [email protected]
Betreff: st: PCA results and new variable

Dear Statalist,
I am performing a PCA analysis of specific firms'(id) characteristics
(varname) within regions.
I would like to know if it possible to create a new variable with the
results of the cumulative of the first component to be assigned to each
firm (id).
Thanks in advance,
Alejandra



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index