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?
asdoc: version update on SSCI have been pushing updates to asdoc through my website, all updates till this date are now part of …
Lasso problems: Extracting coefficients after lasso and then estimating out of sample forecasts in a rolling fashion!!Dear All I have data available at the end of each week (e.g. weekly_predictor1, weekly_predictor2, …
Expanding dataset based on additional end yearsHi everyone, I have a dataset of yearly social capital index based on county codes (FIPS). Based on…
Compare OLS (robust or (clusters) and PPML ( Poisson Psedo- Maximum Like hood)?Hello Can you help me to explain the difference between OLS (robust or (clusters) and PPML ( Poisson…
svysetting a pooled cross sectional dataDear Statalisters, I am working on a household survey with pooled cross-sectional data with the fol…
Subscribe to:
Post Comments (Atom)
0 Response to How to make it as a program?
Post a Comment