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
Assigning value from one variable to another if condition is metI have a data manipulation question: I have a dataset with the variables "id_1", "year", and "id_2."…
Renaming Matrix Rows With SpacesSuppose I wish to rename the rows of a matrix. Code: clear * cls matrix A = (2,1\3,2) cls loc rn …
Is it possible that log mis-calculates it or create weird ".b" when the workload is too heavy?I use Stata 17 (24 cores). I am sorry that I cannot provide the reproducible example because this p…
Extracting All Strings After a Word within a Variable NameI have a dataset representing a treated unit (GDP), a series of estimated counterfactuals, (cf) and …
How to use xtcointtest with runby? OR How to do cointegration tests for each individuals separately for panel data?Dear all: I'm trying to use xtcointtest to do cointegration tests for each individuals separately in…
Subscribe to:
Post Comments (Atom)
0 Response to cannot use NL with weights and cluster-robust
Post a Comment