Hi STATALIST,
Following program supposed to give me 100 different MSEs, but it produced 100 same MSEs. could anyone please help me to find out the problem?
Regards,

Following program supposed to give me 100 different MSEs, but it produced 100 same MSEs. could anyone please help me to find out the problem?
Regards,
Code:
clear
clear matrix
capture log close
pause on
log using "C:\internal validation CT.log", text replace
capture program drop nfoldmseCT
program define nfoldmseCT
local N `2'
local i=1
postfile mysim mse using nfoldmseCT-estimates, replace
set seed 34561
while `i' <= `1' {
drop _all
use "C:\internal validation CT.dta", clear
quietly nbreg CTexamsnumber CTunitsdensitypermillionp un2016poulation65years undp2017humandevelopmentinde if sample==0 , exposure(un2015populationtotal1000) irr vce(robust)
drop if sample==0
sample `N', count
predict predict_rate_CT if sample==1, ir
gen diff =.
replace diff = (predict_rate_CT - CTexamsdensityperthousand)^2 if sample==1
quietly summarize diff, detail
local mse = (r(mean))
post mysim (`mse')
local i=`i'+1
}
postclose mysim
use nfoldmseCT-estimates, clear
end
nfoldmseCT 100 77
/* 100 samples of size 77 */
list
summarize mse

Comment