Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Why `sums'[_N] in stata module kernreg1


From   Yibing Wang <[email protected]>
To   [email protected]
Subject   st: Why `sums'[_N] in stata module kernreg1
Date   Wed, 28 May 2003 01:08:47 -0700 (PDT)

Dear Statalisters,

I tried to use the Stata module kernreg1 
(KERNREG1: Stata module to compute kernel regression
(Nadaraya-Watson estimator)
http://ideas.repec.org/s/boc/bocode1.html)

program define kernreg1
  version 3.1

...
...

while `count'<=`np' {
    replace `xo'=`gridp'[`count']
    replace `z'=(`xo'-`xvar')/`h'
    if `kc'==1 {
        replace `kz'=0.5 if abs(`z')<=1 & `use'
    }
    else if `kc'==2 {
        replace `kz'=(1-abs(`z')) if abs(`z')<=1 &
`use'
    }
    ...
    ... 
    
    replace `sums'= sum(`kz')
    replace `sums2'= sum(`kzy')
    replace `fh'=(1/(`nuobs'*`h'))*`sums'[_N] if
_n==`count'
    replace `rh'=(1/(`nuobs'*`h'))*`sums2'[_N] if
_n==`count'
    replace `kz'=0
    replace `kzy'=0
    replace `count'=`count'+1
  }

  if `rh'==0 {
          replace `mh'=0
  }
  else {
          replace `mh'=`rh'/`fh'
  }


My question is why `sums'[_N] is used instead of
`sums' as we are trying to calculate fh from 1 to _N ?

I have been trying to figure it out without success,
can anybody give me some advice?

Any suggestion is highly appreciated,

Thanks,

Yibing

University of Calgary


__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com
*
*   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