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
Splines after Cox-modelDear Stata users, I am trying to draw splines using Stata after Cox-model as shown in the below fig…
-egen, xtile- works in Stata 11, 12, 13, but generates an error message in Stata 15... Is this situation supposed to not occur?Good afternoon, The -egen, xtile- command/function from the egenmore package by Nick Cox is exhibit…
How to make a point estimate in a mixed model with continuous variablesDear Stata users, I have a mixed model (see the syntax below) with main effects of group (two dicho…
How to create new variable with month and year since May, 2011 as n°1Dear Statalister, I'm trying to create a new variable derived from one date (DateACR_num) which inc…
How to deal with unbalanced panel data for Hedonic Price Method?I currently have a micro (5 years) panel data of house price transaction. There are a total of 800 d…
Subscribe to:
Post Comments (Atom)
0 Response to using forvalues loop and postfile command
Post a Comment