Hello,

I want to use the lpoly command to smoothen the outcome variable in a panel.

The question is similar to this:
https://www.statalist.org/forums/for...for-panel-data

However, I would like to store the results (for each parish)

My current attempt looks like this:
Code:
quietly levelsof Parish, local(parids)
foreach Parish of local parids {
lpoly Outcome Time if Parish == `Parish', n(50) gen(kernx kerns) bw(5) nograph
}
I want to create two new columns: "kernx" and "kerns" which are supposed to contain the estimates from the lpoly command.

The problem is that this works for the first Parish, but not for the following.

Thanks for your help!


Heres an example of my (fake) data:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double(Parish Time Outcome)
1  1 0
1  2 1
1  3 2
1  4 2
1  5 2
1  6 2
1  7 0
1  8 1
1  9 2
1 10 1
1 11 0
1 12 1
1 13 2
1 14 1
1 15 2
1 16 1
1 17 2
1 18 1
1 19 2
1 20 1
1 21 2
1 22 0
1 23 1
1 24 0
1 25 2
1 26 2
1 27 2
1 28 0
1 29 2
1 30 2
1 31 1
1 32 2
1 33 0
1 34 2
1 35 0
1 36 2
1 37 2
1 38 0
1 39 0
1 40 0
1 41 2
1 42 2
1 43 0
1 44 1
1 45 1
1 46 1
1 47 2
1 48 2
1 49 1
1 50 2
2  1 0
2  2 2
2  3 1
2  4 2
2  5 2
2  6 1
2  7 1
2  8 0
2  9 1
2 10 1
2 11 2
2 12 0
2 13 0
2 14 1
2 15 2
2 16 0
2 17 0
2 18 0
2 19 1
2 20 2
2 21 0
2 22 1
2 23 1
2 24 0
2 25 1
2 26 2
2 27 2
2 28 0
2 29 2
2 30 0
2 31 0
2 32 2
2 33 2
2 34 1
2 35 2
2 36 0
2 37 2
2 38 0
2 39 2
2 40 0
2 41 0
2 42 0
2 43 1
2 44 2
2 45 0
2 46 1
2 47 2
2 48 0
2 49 0
2 50 1
end