Hi All,
I am trying to make this as a program. Any help? Below is my code. Thanks
clear
set seed 123456
set obs 1000
gen auction_id = _n
local bidder = 10
foreach i of numlist 1/`bidder'{
gen bidder`i'= runiform()
}
reshape long bidder,i(auction_id) j(var)
sort auction_id bidder
by auction_id: gen nv=_n
drop var
reshape wide bidder, i(auction_id) j(nv)
quietly summarize bidder9,detail
di r(p25)
di r(p75)
tempname IQR
scalar `IQR'= r(p75)-r(p25)
egen sd=sd( bidder9)
tempname sd h
scalar `sd' = sd
di min(`sd', `IQR'/1.349)*1.06
scalar `h' = min(`sd', `IQR'/1.349)*1.06
kdensity bidder9, kernel(gaussian) bwidth(.12234464) gen(wpdf) at (bidder9)
cumul(bidder9), gen(wcdf)
local line_size `c(linesize)'
set linesize 80
clear mata
mata:
mata set matastrict on
void function createG() {
// Add G to the Stata dataset
(void) st_addvar("double", "G")
// "I have a big dataset with 1000rows, 9colums", so use a view
real matrix View
pragma unset View
st_view(View, ., ("G", "wcdf"))
// Do the arithmetic: "G=10*wcdf^9-9*wcdf^10"
View[., 1] = 10 :* View[., 2]:^9 :- 9 :* View[., 2]:^10
stata("list G wcdf, noobs separator(0)")
}
end
mata: createG()
set linesize `line_size'
exit
Related Posts with How to make it as a program?
Treatment Effect in Panel Data with Many Time Periods and Various Treatment Starts Dear Statalist, I have a question regarding the identification of a treatment effect in a large pa…
serial/cross sectional autocorrelation and heteroscedasticity in panel dataHello everyone, I am working with a paneldataset with N=170 and T=5. I want to test for heterosceda…
Nelson aalen cumulative hazard functionHi all! Hope you are doing good. I have a question about the Nelson aalen cumulative hazard functio…
standard deviation of a variableHi everyone, I have a set data for 10 years. I want to calculate the standard deviation of one varia…
Producting publication tables for loneway commandDear Stata users, I computed different intraclass correlations using the loneway command. Which comm…
Subscribe to:
Post Comments (Atom)
0 Response to How to make it as a program?
Post a Comment