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   "Yan Cheng" <>
Subject   Re: st: How to deal with a lot of exogenous variables in Path analysis (help)
Date   Sun, 11 Mar 2007 09:01:00 +0800

Many thanks for your generous help! I will try to finish my analysis
according to your suggestions.

Thanks again!

Best wishes,

Cheng Yan

2007/3/11, Maarten buis <>:
--- Yan Cheng <> 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: . 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 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'

  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))

 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))
   scalar `ll' = `ll' + e(ll)
   return scalar ll = `ll'

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 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

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.*
*   For searches and help try:

*   For searches and help try:

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