Hello, I want to make simple parametric non-linear least square using nl function.
The problem is I want to put individual fixed effect with 1130 dummy variable.
I want to allow individual heterogeneity on the intercept.
Here is my current code, however, it will take more than 10 hours.
Is there any method I can run the code faster?
I don't have an interest in the specific value of the individual dummy. I just want to control them.
program nldtshare
version 14.0
syntax varlist(min=5 max=5) [aw fw iw] if, at(name)
local dt_share: word 1 of `varlist'
local distance_pre: word 2 of `varlist'
local t: word 3 of `varlist'
local treatment: word 4 of `varlist'
local txtreatment: word 5 of `varlist'
// Retrieve parameters out of at matrix
tempname d0 d1 d2 d3 g0 g1 g2 g3
scalar `d0' = `at'[1,1]
scalar `d1' = `at'[1,2]
scalar `d2' = `at'[1,3]
scalar `d3' = `at'[1,4]
scalar `g0' = `at'[1,5]
scalar `g1' = `at'[1,6]
scalar `g2' = `at'[1,7]
scalar `g3' = `at'[1,8]
tempvar dterm gterm indv
generate double `dterm' = `d0'+`d1'*`t'+`d2'*`treatment'+`d3'*`txtreatment' `if'
generate double `gterm' = `g0'+`g1'*`t'+`g2'*`treatment'+`g3'*`txtreatment' `if'
replace `dt_share' = `dterm'*(`distance_pre')^`gterm' `if'
local atcnt=9
forval i=1/1130{
replace `dt_share'=`dt_share'+`at'[1,`atcnt']*(id==`i') `if'
local `++atcnt'
}
end
The problem is I want to put individual fixed effect with 1130 dummy variable.
I want to allow individual heterogeneity on the intercept.
Here is my current code, however, it will take more than 10 hours.
Is there any method I can run the code faster?
I don't have an interest in the specific value of the individual dummy. I just want to control them.
program nldtshare
version 14.0
syntax varlist(min=5 max=5) [aw fw iw] if, at(name)
local dt_share: word 1 of `varlist'
local distance_pre: word 2 of `varlist'
local t: word 3 of `varlist'
local treatment: word 4 of `varlist'
local txtreatment: word 5 of `varlist'
// Retrieve parameters out of at matrix
tempname d0 d1 d2 d3 g0 g1 g2 g3
scalar `d0' = `at'[1,1]
scalar `d1' = `at'[1,2]
scalar `d2' = `at'[1,3]
scalar `d3' = `at'[1,4]
scalar `g0' = `at'[1,5]
scalar `g1' = `at'[1,6]
scalar `g2' = `at'[1,7]
scalar `g3' = `at'[1,8]
tempvar dterm gterm indv
generate double `dterm' = `d0'+`d1'*`t'+`d2'*`treatment'+`d3'*`txtreatment' `if'
generate double `gterm' = `g0'+`g1'*`t'+`g2'*`treatment'+`g3'*`txtreatment' `if'
replace `dt_share' = `dterm'*(`distance_pre')^`gterm' `if'
local atcnt=9
forval i=1/1130{
replace `dt_share'=`dt_share'+`at'[1,`atcnt']*(id==`i') `if'
local `++atcnt'
}
end
Comment