I am trying to run loop within loop and get the p values in the matrix. I want to assign random treatment (post) to the non treated countries in the same year and run the regression for 3 different outcome variables for 50 times in a loop. And then get the value of p in the matrix. Can anyone please help me.
I am doing the following. I am either getting the matrix table with missing p values (.) or getting conformability error. please help !!
drop random
drop post
set more off
set matsize 800
set seed 6000
unab y : wheat rice lentils
local l : word count `y'
matrix p = J(50,`l',.)
matrix colnames p =`y'
matlist p
foreach i of numlist 1/50 {
generate random=uniform()
sort year random
generate post=0
replace post=1 in 1 in 1/29 // for year 2010
replace post=1 in 296/337 // for year 2011
replace post=1 in 578/619 // for year 2012
foreach var of local y {
quietly reg `var' post i.country_id i.year i.country#c.line_time_trend [aw=ypop], cluster( country_id )
matrix p[1,`i++'] = 2*ttail(e(df_r), abs(_b[post]/_se[post]))
}
drop random
drop post
}
matlist p
Related Posts with Running a loop n times with different outcome variable and storing the p values in an output matrix
do standard errors in -margins- after -meglm- account for the (EB) random effect variance?I am working with a meglm model, and need to produce margins out of it. Based on the [ME] meglm post…
wbopendata query error 23Hi all, I've been running into the following error for several days now: wbopendata query erro…
Average Marginal effects for a multilevel modelHi, Please, I wanted to know the appropriateness of deriving marginal effects from a multilevel mod…
How to colour bars in a histogram or graph barHi there, I have been trying to colour individual bars in a histogram or graph bar with percentages…
problem installing using the ssc commandI am using Stata/MC 16.1 on Windows 10 (also had the same problem using Ubuntu Linux 18.04). I have…
Subscribe to:
Post Comments (Atom)
0 Response to Running a loop n times with different outcome variable and storing the p values in an output matrix
Post a Comment