With a Census data, i have a column ("A") with household control numbers (same numbers=same family), another column ("B") that informs me if the observation is from the owner of the house or his/her children/husband/wife. What i need is to create a column ("D") that replicate for all members in the house the values found in the third column ("C") of the owner. Something like this:

A | B | C | D |

1 | Owner | 1 | 1 |

1 | other | 2 | 1 |

1 | other | 3 | 1 |

1 | other | 4 | 1 |

2 | owner | 5 | 5 |

2 | other | 6 | 5 |

2 | other | 7 | 5 |

3 | owner | 8 | 8 |

3 | other | 9 | 8 |

3 | other | 10 | 8 |

Any ideas?

]]>

:

Cumby-Huizinga test for autocorrelation (Breusch-Godfrey) H0: variable is MA process up to order q HA: serial correlation present at specified lags >q ----------------------------------------------------------------------------- H0: q=0 (serially uncorrelated) | H0: q=specified lag-1 HA: s.c. present at range specified | HA: s.c. present at lag specified -----------------------------------------+----------------------------------- lags | chi2 df p-val | lag | chi2 df p-val -----------+-----------------------------+-----+----------------------------- 1 - 1 | 15.242 1 0.0001 | 1 | 15.242 1 0.0001 1 - 2 | 15.255 2 0.0005 | 2 | 3.300 1 0.0693 1 - 3 | 15.325 3 0.0016 | 3 | 1.192 1 0.2749 1 - 4 | 15.896 4 0.0032 | 4 | 0.000 1 0.9880 1 - 5 | 16.057 5 0.0067 | 5 | 1.113 1 0.2914 1 - 6 | 16.078 6 0.0133 | 6 | 2.051 1 0.1521 1 - 7 | 16.087 7 0.0243 | 7 | 1.902 1 0.1679 1 - 8 | 16.211 8 0.0395 | 8 | 1.579 1 0.2090 1 - 9 | 16.932 9 0.0498 | 9 | 1.582 1 0.2085 1 - 10 | 19.571 10 0.0336 | 10 | 2.411 1 0.1205 1 - 11 | 20.095 11 0.0441 | 11 | 2.264 1 0.1324 1 - 12 | 22.640 12 0.0309 | 12 | 1.619 1 0.2032 ----------------------------------------------------------------------------- Test allows predetermined regressors/instruments Test requires conditional homoskedasticity

Baum and Schaffer provide extensive comment here: http://fmwww.bc.edu/EC-C/S2014/823/UKSUG2013.pdf. On p. 17 they state that examples from previous pages are univariate time series like the from the module example above. Judging by their comments on p. 15, are the tests on the left side cumulative? So the first row tests:

H

H

The next row tests:

H

H

and so on, correct?

For the right side, it's not clear what the null hypothesis is. According to p. 15 in the presentation, it involves lag-1 as shown, but the meaning in terms of the hypothesis escapes me. The alternates appear to be testing cigsales

]]>

I have panel data since 1988 to 2011 and in order to use a Differences in Differences (DiD) strategy, I need to generate a variable that equals the change between two years of the panel. At first, I used the following code:

:

foreach var of varlist[list of variables] { gen D`var' = D.`var' }

There is a way I can do this using a loop? I have tried .S option, but I am not having good results.

Thanks in advance,

Iván Higuera

]]>

Therefore, I decided to use -xthtaylor- because that seems to be the best solution. However, there's only 1 not so clear example on the Internet (I searched for about 30-45 minutes for another example).

Based on the example of https://kb.iu.edu/d/bcfo the variable -ed- is the endogenous time-invariant regressor but when I look at that data, -ed- seems to change over time.

In my case, Male (gender) (and MBA) do not change over time and my other independent variables do change over time (I assume they're endogenous time-varying variables based on the error below)

:

xthtaylor alpha MRP SMB HML MOM Male, endog(Male) constant(Male) xthtaylor alpha MRP SMB HML MOM Male, endog(MRP SMB HML MOM) constant(Male)

If you have those variables specified, they may have been removed because of collinearity."

Hopefully someone can help me.

Kind regards,

Victoria]]>

svyset[pweight=perwt], vce(brr) brrweight(repwtp1-repwtp80) fay(.5)mse

After my regression, I want to compute margins with standard errors based on balanced repeated replications (brr). I followed the advice on the Stata manual svy.pdf page 115.

Here is my code:

capture program drop mymargins

program mymargins, eclass

version 13

syntax anything [if] [iw pw]

if "`weight'" != "" {

local wgtexp "[`weight' `exp']"

}

set buildfvinfo on

`anything' `if' `wgtexp'

margins groups1, at (age=(50(5)80))subpop(samp) atmeans

end

svyset[pweight=perwt], vce(brr) brrweight(repwtp1-repwtp80) fay(.5)mse

local mycmdline svy, subpop(samp): logistic physdis ib4.groups1 age female

quietly mymargins `mycmdline'

svy brr _b: mymargins `mycmdline'

However, I am getting an error that says "options not allowed r(101);" after the line quietly mymargins `mycmdline'

Thanks a lot for your help,

Susana]]>

We have a small study (n = 37) attempting to use MRI to predict whether or not a patient has a particular type of tumor (astrocytoma). I wanted to use bootstrapping for validation however I was not sure what stata commands I would need to use in order to do this. Any guidance would be much appreciated.

Thanks,

Anand]]>

svyset[pweight=perwt], vce(brr) brrweight(repwtp1-repwtp80) fay(.5)mse

After my regression, I want to compute margins with standard errors based on balanced repeated replications (brr). I followed the advice on the Stata manual svy.pdf page 115.

Here is my code:

capture program drop mymargins

program mymargins, eclass

version 13

syntax anything [if] [iw pw]

if "`weight'" != "" {

local wgtexp "[`weight' `exp']"

}

set buildfvinfo on

`anything' `if' `wgtexp'

margins groups1, at (age=(50(5)80))subpop(samp) atmeans

end

svyset[pweight=perwt], vce(brr) brrweight(repwtp1-repwtp80) fay(.5)mse

local mycmdline svy, subpop(samp): logistic physdis ib4.groups1 age female

quietly mymargins `mycmdline'

svy brr _b: mymargins `mycmdline'

However, I am getting an error that says "options not allowed r(101);" after the line quietly mymargins `mycmdline'

Thanks a lot for your help,

Susana]]>

I am using following command to estimate a panel probit model

For the results table I would like to report beta (standardized coef and se). I used estadd listcoef with probit, but it does not run for xtprobit. So how can I list beta coef. I am not sure that estadd beta works with xtprobit

Also, xtprobit, pa option does not save scalars like pseudo r2 ll constant only or other. How can report / calculate pseudo r2 ?

thanks a lot!

]]>

So I want to transform my equation like

Y(t)’=Y(t) - Y(t-1).

My problem is whether i have to lag my dependent variable separately or if the command “hlu” lags it automatically.

So, is the command:

1. hlu Y X Y(t-1), nolog

or

2. hlu Y X, nolog

]]>

I have the following dataset

input id num1 num2 num3 num4 num5

1 12 1 14 55 15

1 12 1 14 145 15

2 99 9 97 4 96

2 99 9 97 23 96

2 99 9 97 200 96

3 55 3 4 3 22

end

I noted that the dataset contains some duplicate observations in terms of all variables but num4.

Therefore, I would like to collapse these duplicate observations into a single row by summing up the value of num4.

To illustrate the final dataset should consists of three rows as the following:

input id num1 num2 num3 num4 num5

1 12 1 14 200 15

2 99 9 97 227 96

3 55 3 4 3 22

end

I'm not sure what is the quickest way to do this. Can I kindly ask you to help me with this?

Thank you in advance.

Best regards,

F]]>

I have a dataset with students within classes. I calculated the intra class coefficient already (as a part of the multilevel analysis).

But now I also want to know how similar the answers within the classes are.

Backround: The students were asked to rate the frequencies for different classroom activities in the last few month (e.g. reading a book, watching a movie etc). I want to know if the students in one class experienced the lessons in the same way/remember it the same way. Obviously a great discrepancy would be a bad thing for me, since it would mean, that students in the same class perceived the lessons very differently.

I can't come up with a procedure to get what I want. Do I need to calculate a correlation seperately for each student with every other student in his/her class? Do I need to reshape the dataset to show every class in one row, almost treating it like a inter-rater reliablity test where every students is one 'rater' rating the same issue?

Any suggestions would be greatly appreciated ]]>

Manoj

* function evaluator program ***************************** program nlsuraids

version 13

syntax varlist(min=18 max=18) if, at(name)

tokenize `varlist'

args w1 w2 w3 w4 w5 w6 w7 w8 lnp1 lnp2 lnp3 lnp4 lnp5 lnp6 lnp7 lnp8 lnp9 lnm

tempname a1 a2 a3 a4 a5 a6 a7 a8 a9

scalar `a1' = `at'[1,1]

scalar `a2' = `at'[1,2]

scalar `a3' = `at'[1,3]

scalar `a4' = `at'[1,4]

scalar `a5' = `at'[1,5]

scalar `a6' = `at'[1,6]

scalar `a7' = `at'[1,7]

scalar `a8' = `at'[1,8]

scalar `a9' = 1 - `a1' - `a2' - `a3'- `a4' - `a5' - `a6'- `a7' - `a8'

tempname b1 b2 b3 b4 b5 b6 b7 b8

scalar `b1' = `at'[1,9]

scalar `b2' = `at'[1,10]

scalar `b3' = `at'[1,11]

scalar `b4' = `at'[1,12]

scalar `b5' = `at'[1,13]

scalar `b6' = `at'[1,14]

scalar `b7' = `at'[1,15]

scalar `b8' = `at'[1,16]

tempname g11 g12 g13 g14 g15 g16 g17 g18 g19

tempname g21 g22 g23 g24 g25 g26 g27 g28 g29

tempname g31 g32 g33 g34 g35 g36 g37 g38 g39

tempname g41 g42 g43 g44 g45 g46 g47 g48 g49

tempname g51 g52 g53 g54 g55 g56 g57 g58 g59

tempname g61 g62 g63 g64 g65 g66 g67 g68 g69

tempname g71 g72 g73 g74 g75 g76 g77 g78 g79

tempname g81 g82 g83 g84 g85 g86 g87 g88 g89

tempname g91 g92 g93 g94 g95 g96 g97 g98 g99

scalar `g11' = `at'[1,17]

scalar `g12' = `at'[1,18]

scalar `g13' = `at'[1,19]

scalar `g14' = `at'[1,20]

scalar `g15' = `at'[1,21]

scalar `g16' = `at'[1,22]

scalar `g17' = `at'[1,23]

scalar `g18' = `at'[1,24]

scalar `g19' = -`g11'-`g12'-`g13'-`g14'-`g15'-`g16'-`g17'-`g18'

scalar `g21' = `g12'

scalar `g22' = `at'[1,25]

scalar `g23' = `at'[1,26]

scalar `g24' = `at'[1,27]

scalar `g25' = `at'[1,28]

scalar `g26' = `at'[1,29]

scalar `g27' = `at'[1,30]

scalar `g28' = `at'[1,31]

scalar `g29' = -`g21'-`g22'-`g23'-`g24'-`g25'-`g26'-`g27'-`g28'

scalar `g31' = `g13'

scalar `g32' = `g23'

scalar `g33' = `at'[1,32]

scalar `g34' = `at'[1,33]

scalar `g35' = `at'[1,34]

scalar `g36' = `at'[1,35]

scalar `g37' = `at'[1,36]

scalar `g38' = `at'[1,37]

scalar `g39' = -`g31'-`g32'-`g33'-`g34'-`g35'-`g36'-`g37'-`g38'

scalar `g41' = `g14'

scalar `g42' = `g24'

scalar `g43' = `g34'

scalar `g44' = `at'[1,38]

scalar `g45' = `at'[1,39]

scalar `g46' = `at'[1,40]

scalar `g47' = `at'[1,41]

scalar `g48' = `at'[1,42]

scalar `g49' = -`g41'-`g42'-`g43'-`g44'-`g45'-`g46'-`g47'-`g48'

scalar `g51' = `g15'

scalar `g52' = `g25'

scalar `g53' = `g35'

scalar `g54' = `g45'

scalar `g55' = `at'[1,43]

scalar `g56' = `at'[1,44]

scalar `g57' = `at'[1,45]

scalar `g58' = `at'[1,46]

scalar `g59' = -`g51'-`g52'-`g53'-`g54'-`g55'-`g56'-`g57'-`g58'

scalar `g61' = `g16'

scalar `g62' = `g26'

scalar `g63' = `g36'

scalar `g64' = `g46'

scalar `g65' = `g56'

scalar `g66' = `at'[1,47]

scalar `g67' = `at'[1,48]

scalar `g68' = `at'[1,49]

scalar `g69' = -`g61'-`g62'-`g63'-`g64'-`g65'-`g66'-`g67'-`g68'

scalar `g71' = `g17'

scalar `g72' = `g27'

scalar `g73' = `g37'

scalar `g74' = `g47'

scalar `g75' = `g57'

scalar `g76' = `g67'

scalar `g77' = `at'[1,50]

scalar `g78' = `at'[1,51]

scalar `g79' = -`g71'-`g72'-`g73'-`g74'-`g75'-`g76'-`g77'-`g78'

scalar `g81' = `g18'

scalar `g82' = `g28'

scalar `g83' = `g38'

scalar `g84' = `g48'

scalar `g85' = `g58'

scalar `g86' = `g68'

scalar `g87' = `g78'

scalar `g88' = `at'[1,52]

scalar `g89' = -`g81'-`g82'-`g83'-`g84'-`g85'-`g86'-`g87'-`g88'

scalar `g91' = `g19'

scalar `g92' = `g29'

scalar `g93' = `g39'

scalar `g94' = `g49'

scalar `g95' = `g59'

scalar `g96' = `g69'

scalar `g97' = `g79'

scalar `g98' = `g89'

scalar `g99' = -`g91'-`g92'-`g93'-`g94'-`g95'-`g96'-`g97'-`g98'

quietly {

tempvar

gen double `lnpindex' = 5 + `a1'*`lnp1' + `a2'*`lnp2' + `a3'*`lnp3' + ///

`a4'*`lnp4' + `a5'*`lnp5' + `a6'*`lnp6' + ///

`a7'*`lnp7' + `a8'*`lnp8' + `a9'*`lnp9'

forvalues i = 1/9 {

forvalues j = 1/9 {

replace `lnpindex' = `lnpindex' + 0.5*`g`i'`j''*`lnp`i''*`lnp`j''

}

}

replace `w1' = `a1' + `g11'*`lnp1' + `g12'*`lnp2' + `g13'*`lnp3' +///

`g14'*`lnp4' + `g15'*`lnp5'+ `g16'*`lnp6' +///

`g17'*`lnp7' + `g18'*`lnp8'+ `g19'*`lnp9' +///

`b1'*(`lnm' - `lnpindex')

replace `w2' = `a2' + `g21'*`lnp1' + `g22'*`lnp2' + `g23'*`lnp3' +///

`g24'*`lnp4' + `g25'*`lnp5'+ `g26'*`lnp6' +///

`g27'*`lnp7' + `g28'*`lnp8'+ `g29'*`lnp9' +///

`b2'*(`lnm' - `lnpindex')

replace `w3' = `a3' + `g31'*`lnp1' + `g32'*`lnp2' + `g33'*`lnp3' +///

`g34'*`lnp4' + `g35'*`lnp5'+ `g36'*`lnp6' +///

`g37'*`lnp7' + `g38'*`lnp8'+ `g39'*`lnp9' +///

`b3'*(`lnm' - `lnpindex')

replace `w4' = `a4' + `g41'*`lnp1' + `g42'*`lnp2' + `g43'*`lnp3' +///

`g44'*`lnp4' + `g45'*`lnp5'+ `g46'*`lnp6' +///

`g47'*`lnp7' + `g48'*`lnp8'+ `g49'*`lnp9' +///

`b4'*(`lnm' - `lnpindex')

replace `w5' = `a5' + `g51'*`lnp1' + `g52'*`lnp2' + `g53'*`lnp3' +///

`g54'*`lnp4' + `g55'*`lnp5'+ `g56'*`lnp6' +///

`g57'*`lnp7' + `g58'*`lnp8'+ `g59'*`lnp9' +///

`b5'*(`lnm' - `lnpindex')

replace `w6' = `a6' + `g61'*`lnp1' + `g62'*`lnp2' + `g63'*`lnp3' +///

`g64'*`lnp4' + `g65'*`lnp5'+ `g66'*`lnp6' +///

`g67'*`lnp7' + `g68'*`lnp8'+ `g69'*`lnp9' +///

`b6'*(`lnm' - `lnpindex')

replace `w7' = `a7' + `g71'*`lnp1' + `g72'*`lnp2' + `g73'*`lnp3' +///

`g74'*`lnp4' + `g75'*`lnp5'+ `g76'*`lnp6' +///

`g77'*`lnp7' + `g78'*`lnp8'+ `g79'*`lnp9' +///

`b7'*(`lnm' - `lnpindex')

replace `w8' = `a8' + `g81'*`lnp1' + `g82'*`lnp2' + `g83'*`lnp3' +///

`g84'*`lnp4' + `g85'*`lnp5'+ `g86'*`lnp6' +///

`g87'*`lnp7' + `g88'*`lnp8'+ `g89'*`lnp9' +///

`b8'*(`lnm' - `lnpindex')

}

end

nlsur aids @ w1 w2 w3 w4 w5 w6 w7 w8 lnp1 lnp2 lnp3 lnp4 lnp5 lnp6 lnp7 lnp8 lnp9 lnm,parameters(a1 a2 a3 a4 a5 a6 a7 a8 b1 b2 b3 b4 b5 b6 b7 b8 g11 g12 g13 g14 g15 g16 g17 g18 g22 g23 g24 g25 g26 g27 g28 g33 g34 g35 g36 g37 g38 g44 g45 g46 g47 g48 g55 g56 g57 g58 g66 g67 g68 g77 g78 g88) nequations(8) ifgnls

]]>

I am estimating Arellano-Bover/Blundell-Bond dynamic panel estimator and I am getting the "Error no observations when conducting xtdpdsys" error message. My immediate guess is that Stata is deleting the all the rows with missing values (my lagged values of endogeous regressors) which are my predetermined variables. Is their a way I can get around this?

Thanks.]]>