Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: How to deal with a lot of exogenous variables in Path analysis (help)


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: How to deal with a lot of exogenous variables in Path analysis (help)
Date   Sat, 10 Mar 2007 20:17:24 +0000 (GMT)

--- Yan Cheng <[email protected]> wrote:
> 1. I have two behavior-related endogenous variables  'risk behavior'
> and 'sexual behavior', I assume there are correlation not causal
> relationship between risk behavior and sex, then how do I show their
> correlation in the syntax?

pathreg (knowledge exogenous_vars) /*
*/ (attitude knowledge exegenous_vars) /*
*/ (risk_behavior attitude knowledge exogenous_vars) /*
*/ (sex attitude knowledge exogenous_vars)

> 2. How to calculate the path coefficients of dummy variables? For
> example, I divided the occupation into 4 categories: worker, peasant,
> clerk and unemployed, the reference group is "unemployed", then how
> to calculate the path coefficients of occupation, should I calculate
> the path coefficients of worker,peasant, clerk respectively? what is
> the meaning of them?

A pathmodel like this is just a series of OLS regressions, and path
coefficients are just standardized coefficients. So, for the continuous
there is not problem (they are reported in the beta column). 

If you think that occupation is just nominal (i.e. the occupations are
just different from one another, nothing else) than you would add
occupation as a series of dummies which would measure how different
each occupation is to the reference occupation (the occupation you
choose to leave out). Standardizing these coeficients makes less sence
and makes them harder to interpret.

If you think there is some latent underlying continuous variable
underlying occupation (e.g. occupational status) than you can estimate
this scale and the effect of the latent occupational status on the
explained variable. I would first do the regression that are part of
the pathmodel seperately and generate a scales for occupation for each
regression separately, like in the example below. The logic behind this
procedure is explained in the appendix of the following working paper:
http://home.fsw.vu.nl/m.buis/wp/distmare.html . You might want to
experiment with trying to set scales equal. Then I would enter the
scaled variables into -pathreg-

> 3. Are there any indice to show the goodiness of the model?

Based on my intuition and by analogy of other models I know *but not on
any formal argument* I would guess you can just add the log likelihoods
to get the log likelihood of the entire model. -pathreg- does not do
that for you, so I created a new program for you -pathreg2- which I put
below. It works the same way as -pathreg- only the log likelihood is
return as r(ll).
 
> 4. Before the path analysis, should I conduct the correlation
> analysis among all of variables? If so, cause I have different types
> of variables (continuous, ordianl and categorical), are there any
> command to conduct the analysis at one time?

The correlation analysis in
http://www.ats.ucla.edu/stat/Stata/faq/pathreg.htm is used to fill in
the ``curvy'' line. These are typically the least interesting, so if
you want you can leave them out.


*------------------- begin example for question 2 ------------------
sysuse auto, clear

/*category 1 is very small*/
recode rep78 1=2  

/*generate dummies*/
gen rep3 = rep78==3 if rep78<.
gen rep4 = rep78==4 if rep78<.
gen rep5 = rep78==5 if rep78<.

reg price mpg rep3-rep5

/*rep782 is the scaled version of rep78*/
gen double rep782 = rep78 if !missing(price,mpg,rep78)
local b3 = _b[rep3]/_b[rep5]
local b4 = _b[rep4]/_b[rep5]
recode rep782 (2=0) ///
              (3 = `b3') ///
              (4 = `b4') ///
              (5 = 1)
reg price mpg rep782
*-------------------- end example for question 2 ----------------------



*--------------- begin program for question 3 -------------------
*! MLB 1.0.0 10 Mar 2007
*! based on pathreg version 1.0 -- 11/8/01 -- pbe
program define pathreg2, rclass
  version 7
/*  syntax varlist [aw fw] [if] [in] */
   tempname ll	
   tempvar touse
   local totvar "`0'"
   local totvar = subinstr("`totvar'", "(", " ",.)
   local totvar = subinstr("`totvar'", ")", " ",.)
   mark `touse'
   markout `touse' `totvar'
   display

   GetEq `0'
   local vl1 `s(varlist)'
   regress `vl1' if `touse', beta noheader
   scalar `ll' = e(ll)	
   display _skip(17) /*
   */ in green "n = " in yellow e(N)  /*
   */ in green "  R2 = "  in yellow %6.4f e(r2) /*
   */ in green "  sqrt(1 - R2) = " in yellow %6.4f sqrt(1-e(r2))   
   display

  while `"`s(rest)'"' ~= "" {
    GetEq `s(rest)'
    local vl1 `s(varlist)'
    regress `vl1' if `touse', beta noheader
    display _skip(17) /*
    */ in green "n = "  in yellow e(N) /*
    */ in green "  R2 = " in yellow %6.4f e(r2) /*
    */ in green "  sqrt(1 - R2) = " in yellow %6.4f sqrt(1-e(r2))
    display
    scalar `ll' = `ll' + e(ll)
    return scalar ll = `ll'	
 }
end

program define GetEq, sclass 
	sret clear
	gettoken open 0 : 0, parse("(") 
	if `"`open'"' != "(" {
		error 198
	}
	gettoken next 0 : 0, parse(")")
	while `"`next'"' != ")" {
		if `"`next'"'=="" { 
			error 198
		}
		local list `list'`next'
		gettoken next 0 : 0, parse(")")
	}
	sret local rest `"`0'"'
	tokenize `list', parse(" :")
	if "`2'"==":" {
		sret local name "`1'"
		mac shift 2
	}
	local 0 `*'
	syntax varlist
	sret local varlist "`varlist'"
end
*----------------- end program for question 3 ---------------

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


		
___________________________________________________________ 
What kind of emailer are you? Find out today - get a free analysis of your email personality. Take the quiz at the Yahoo! Mail Championship. 
http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk 
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index