Hi all,
I use substitutable expression program to run non-linear least squares (nl). I try to use both weights and cluster-robust standard error, however, I get error: "weights not allowed with vce()". Is there anyway I can get around this in Stata?
I attach the part of codes that matter.
capture program drop nlmain
program nlmain
version 15
syntax varlist [if], at(name)
tokenize `varlist'
// extract parameters
tempname b0 lambda theta b11 b12
scalar `b0' = `at'[1,1]
scalar lambda = `at'[1,2]
scalar theta = `at'[1,3]
scalar `b11' = `at'[1,4]
scalar `b12' = `at'[1,5]
update_exp
replace `1' = `b11'* inc_tile_exp + `b12' * edu_exp + `b0' `if'
// add controls
foreach i of numlist 6/`=n_col +2'{
tempname par`i'
scalar `par`i'' = `at'[1,`i']
}
foreach i of numlist 6/`=n_col+2'{
local ii = `i' - 4
replace `1' = `1' + `par`i'' * ``ii''
}
end
nl main @ pstk `control' , parameters("`par'") initial(myvals) hasconstant(b0) vce(cluster cohort)
Thank you,
Dickson Zhu
Related Posts with cannot use NL with weights and cluster-robust
Generating summarized variables for synthetic control predictorsHello, I am setting up a synthetic control based on data that looks something like this: cityid | ye…
Id variable stored in double formatHello Stata members, I am analysing dataset in which pid is stored in double format. Since I want t…
Generating an average of 3 x variables with a rule that at least 2 need to not be missingHi Folks, simple question here that I can't get my head around. I have 3 x blood pressure values pe…
Reshaping dta from long to wide formatHi there, I am fairly new to Stata. I am needing help in reshaping a database from long to wide. I h…
Panel data (i , j and t ) 2SLS using fixed effects when endogenous variable only varies over timeI have emissions data on c.1300 firms, over 10 years, across 27 EU countries. I am looking at the re…
Subscribe to:
Post Comments (Atom)
0 Response to cannot use NL with weights and cluster-robust
Post a Comment