Chow tests with quadratic terms on random noise

Stata code:

clear
set seed 7840348
global TRIALS = 1000

local passed = 0
local passed_sq = 0

forvalues i = 1 / $TRIALS {
	clear
	qui set obs 100
	local s = int(uniform()*1000000)
	set seed `s'

	gen y = rnormal()
	gen x = uniform()
	gen xsq = x^2
	
	gen sa = (x<.5)
	gen x_sa = x*sa
	gen xsq_sa = xsq*sa
	
	gen sb = !sa
	gen x_sb = x*sb
	gen xsq_sb = xsq*sb

	qui reg y sa x_sa sb x_sb, nocons
	qui test _b[x_sb]=_b[x_sa], notest
	qui test _b[sb]=_b[sa], accum
	if (`r(p)' < 0.05) local passed_ = `passed' + 1
	
	qui reg y sa x_sa xsq_sa sb x_sb xsq_sb, nocons
	qui test _b[xsq_sb]=_b[xsq_sa], notest
	qui test _b[x_sb]=_b[x_sa], accum
	qui test _b[sb]=_b[sa], accum
	if (`r(p)' < 0.05) local passed_sq = `passed_sq' + 1
}

di `passed'
di `passed_sq'

Output:

. di `passed'
0

. di `passed_sq'
40

In related news, Andrew Gelman is right.

<span>%d</span> bloggers like this: