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?
rangestat questionHellow I have a question in rangestat why do I always get the result that never calculates? My mean …
Panel data with small T small N and endogenous variableI have a panel data with small T (T = 11) small N (N=18) with 01 endogenous variable. Which methodol…
Partial options and excluded instruments in xtivreg2Dear all, I am looking to the impact of immigration on firm level outcomes during the period 2006-2…
Treatments before running fractional probit modelHi, I am using a dataset for 25 countries over the period of 5 years (balanced panel) with a few mis…
Staggered difference in differenceHi, I need to run a difference in difference, but I'm not sure how to construct a formula for this.…
Subscribe to:
Post Comments (Atom)
0 Response to How to make it as a program?
Post a Comment