Dear statalist
i have a sample of only 3 observation, i having problem calculating outer product of the gradient , the gradient and updating formula using forvalues loop and postfile command, i get an error message "post sim not found" another question could i use a variable or macro to hold the opg, gr and theta instead of scalar, any help would be greatly appreciated , my do file is as follows
clear all
set obs 100
input y
3.5
1
1.5
end
sca theta1 =1
gen f = -1/theta1 + y/theta1^2
tempname sim
tempfile result
postfile `sim' opg gr theta using result, replace
forvalues i=1/100 {
qui {
sca opg`i' = 1/3*(-1/theta`i' + y[1]/theta`i'^2 )^2 + 1/3*(-1/theta`i' + y[2]/theta`i'^2)^2+ 1/3*(-1/theta`i' + y[3]/theta`i'^2)^2 /* calculating OPG for every iteration*/
sca gr`i' = 1/3*(-1/theta`i' + y[1]/theta`i'^2 ) + 1/3*(-1/theta`i' + y[2]/theta`i'^2)+ 1/3*(-1/theta`i' + y[3]/theta`i'^2) /* calculating the gradient at every iteration*/
loc j=`i'+1
sca theta`j' = theta`i' + (opg`i')^-1*gr`i' /* updating formula*/
post sim (opg`i') (gr`i') (theta`j')
}
}
postclose `sim'
use result, clear
i get error message!!!
post sim not found
r(111);
end of do-file
r(111);
Related Posts with using forvalues loop and postfile command
spxtregress, fe with time fixed effectsHi, I'm using spxtregress, fe to fit a model with a spatial lag of the dependent variable. I would …
Interpolation on null values with the most frequent valueHello. In a dataset like this I need to replace the null values of x1 with the most frequent value o…
estimating tfpI have a panel of firm level data, and am trying to estimate firm level total factor productivity by…
Asking for definition of various types of treatment?Borusyak, 2021 has a sentence We further discuss the implications of our results when treatment …
Solution for inlist - expression too longHi Statalisters, I just would like to share a solution for the inlist limit of 10 string arguments,…
Subscribe to:
Post Comments (Atom)
0 Response to using forvalues loop and postfile command
Post a Comment