SHAZAM Community
Ask Your Question

Revision history [back]

Not at present. Suggest you look at Tim Coelli's excellent implementation here:

http://www.uq.edu.au/economics/cepa/frontier.htm

Some of his examples use SHAZAM.

Not at present. Suggest you Yes, this can be done. Here is an example using the data from Greene 4th Edition:

* Stochastic Frontier Model
* Reference: William H. Greene, Econometric Analysis, Fourth Edition,
*            Prentice-Hall, 2000.
*            Section 9.7.1, pp. 394-397.
SAMPLE 1 25
FORMAT (A8,A4,1X,F10.0,F12.0,F11.0,F13.0)
READ (industry.shd) STATE1-STATE2 Q K L NF / SKIPLINE=1 FORMAT 
GENR LQ=LOG(Q)
GENR LK=LOG(K)
GENR LL=LOG(L)
* Least Squares 
OLS LQ LK LL / COEF=BOLS
GEN1 SIG=SQRT($SIG2)

* Set starting values for the non-linear estimation
DIM BETA 5
GEN1 BETA:2=BOLS:3
GEN1 BETA:3=BOLS:1
GEN1 BETA:4=BOLS:2
GEN1 BETA:1=SIG
GEN1 BETA:5=1

GENR CONSTANT=0.5*LOG(2/$PI)
* Define the regression function in a character string
ERROR: (LQ-(B0+BK*LK+BL*LL))
* Specify the density function for the "half-normal" model.
* Use the LOGDEN option on the NL command.
NL 1 / NCOEF=5 LOGDEN START=BETA COEF=BNEW
EQ CONSTANT - 0.5*LOG(SIGMA**2) - 0.5*([ERROR]/SIGMA)**2 &
   + LOG(NCDF(-[ERROR]*LAMBDA/SIGMA))
END
* Recover an estimate for sigma_v (reported as TEST VALUE).
TEST (SIGMA*SIGMA/(1+LAMBDA*LAMBDA))**0.5
* Recover an estimate for sigma_u
TEST (SIGMA*SIGMA*LAMBDA*LAMBDA/(1+LAMBDA*LAMBDA))**0.5

* Calculate the estimated inefficiencies
GEN1 SIGMA=BNEW:1
GEN1 LAMBDA=BNEW:5
GENR Z=(LQ-(BNEW:2+BNEW:3*LK+BNEW:4*LL))*LAMBDA/SIGMA
?DISTRIB Z / PDF=PDFZ
GENR U=SIGMA*LAMBDA/(1+LAMBDA*LAMBDA)*(PDFZ/(1-NCDF(Z))-Z)
FORMAT(1X,A8,A4,F12.4)
PRINT STATE1-STATE2 U / FORMAT
STOP

You can also look at Tim Coelli's excellent implementation here:

http://www.uq.edu.au/economics/cepa/frontier.htm

Some of his examples use SHAZAM.

click to hide/show revision 3
Formatting adjustment

Yes, this can be done. Here is an example using the data from Greene 4th Edition:

* Stochastic Frontier Model
* Reference: William H. Greene, Econometric Analysis, Fourth Edition,
*            Prentice-Hall, 2000.
*            Section 9.7.1, pp. 394-397.
SAMPLE 1 25
FORMAT (A8,A4,1X,F10.0,F12.0,F11.0,F13.0)
READ (industry.shd) STATE1-STATE2 Q K L NF / SKIPLINE=1 FORMAT 
GENR LQ=LOG(Q)
GENR LK=LOG(K)
GENR LL=LOG(L)
 * Least Squares 
OLS LQ LK LL / COEF=BOLS
GEN1 SIG=SQRT($SIG2)

* Set starting values for the non-linear estimation
DIM BETA 5
GEN1 BETA:2=BOLS:3
GEN1 BETA:3=BOLS:1
GEN1 BETA:4=BOLS:2
GEN1 BETA:1=SIG
GEN1 BETA:5=1

GENR CONSTANT=0.5*LOG(2/$PI)
 * Define the regression function in a character string
ERROR: (LQ-(B0+BK*LK+BL*LL))
 * Specify the density function for the "half-normal" model.
* Use the LOGDEN option on the NL command.
NL 1 / NCOEF=5 LOGDEN START=BETA COEF=BNEW
EQ CONSTANT - 0.5*LOG(SIGMA**2) - 0.5*([ERROR]/SIGMA)**2 &
   + LOG(NCDF(-[ERROR]*LAMBDA/SIGMA))
END
 * Recover an estimate for sigma_v (reported as TEST VALUE).
TEST (SIGMA*SIGMA/(1+LAMBDA*LAMBDA))**0.5
 * Recover an estimate for sigma_u
TEST (SIGMA*SIGMA*LAMBDA*LAMBDA/(1+LAMBDA*LAMBDA))**0.5

* Calculate the estimated inefficiencies
GEN1 SIGMA=BNEW:1
GEN1 LAMBDA=BNEW:5
GENR Z=(LQ-(BNEW:2+BNEW:3*LK+BNEW:4*LL))*LAMBDA/SIGMA
?DISTRIB Z / PDF=PDFZ
GENR U=SIGMA*LAMBDA/(1+LAMBDA*LAMBDA)*(PDFZ/(1-NCDF(Z))-Z)
FORMAT(1X,A8,A4,F12.4)
PRINT STATE1-STATE2 U / FORMAT
STOP

You can also look at Tim Coelli's excellent implementation here:

http://www.uq.edu.au/economics/cepa/frontier.htm

Some of his examples use SHAZAM.

Yes, this can be done. done with some fairly straightforward coding.

Here is an example using the data from Greene 4th Edition:(4th Edition) that estimates the Cost Functions with the half Normal Model. You can easily change the density function equation to fit any other type of model.

The files needed for this example are:

frontier.sha

industry.shd

The example .sha file looks like this:

* Stochastic Frontier Model
* Reference: William H. Greene, Econometric Analysis, Fourth Edition,
*            Prentice-Hall, 2000.
*            Section 9.7.1, pp. 394-397.
SAMPLE 1 25
FORMAT (A8,A4,1X,F10.0,F12.0,F11.0,F13.0)
READ (industry.shd) STATE1-STATE2 Q K L NF / SKIPLINE=1 FORMAT 
GENR LQ=LOG(Q)
GENR LK=LOG(K)
GENR LL=LOG(L)

* Least Squares 
OLS LQ LK LL / COEF=BOLS
GEN1 SIG=SQRT($SIG2)

* Set starting values for the non-linear estimation
DIM BETA 5
GEN1 BETA:2=BOLS:3
GEN1 BETA:3=BOLS:1
GEN1 BETA:4=BOLS:2
GEN1 BETA:1=SIG
GEN1 BETA:5=1

GENR CONSTANT=0.5*LOG(2/$PI)

* Define the regression function in a character string
ERROR: (LQ-(B0+BK*LK+BL*LL))

* Specify the density function for the "half-normal" model.
* Use the LOGDEN option on the NL command.
NL 1 / NCOEF=5 LOGDEN START=BETA COEF=BNEW
EQ CONSTANT - 0.5*LOG(SIGMA**2) - 0.5*([ERROR]/SIGMA)**2 &
   + LOG(NCDF(-[ERROR]*LAMBDA/SIGMA))
END

* Recover an estimate for sigma_v (reported as TEST VALUE).
TEST (SIGMA*SIGMA/(1+LAMBDA*LAMBDA))**0.5

* Recover an estimate for sigma_u
TEST (SIGMA*SIGMA*LAMBDA*LAMBDA/(1+LAMBDA*LAMBDA))**0.5

* Calculate the estimated inefficiencies
GEN1 SIGMA=BNEW:1
GEN1 LAMBDA=BNEW:5
GENR Z=(LQ-(BNEW:2+BNEW:3*LK+BNEW:4*LL))*LAMBDA/SIGMA
?DISTRIB Z / PDF=PDFZ
GENR U=SIGMA*LAMBDA/(1+LAMBDA*LAMBDA)*(PDFZ/(1-NCDF(Z))-Z)
FORMAT(1X,A8,A4,F12.4)
PRINT STATE1-STATE2 U / FORMAT
STOP

You can also look at Tim Coelli's excellent implementation here:

http://www.uq.edu.au/economics/cepa/frontier.htm

Some of his examples use SHAZAM.

Yes, this can be done with some fairly straightforward coding.

Here is an example using the data from Greene (4th Edition) that estimates the to estimate Cost Functions with the half Normal Model. You can easily change the density function equation to fit any other type of model.

The files needed for this example are:

frontier.sha

industry.shd

The example .sha file looks like this:

* Stochastic Frontier Model
* Reference: William H. Greene, Econometric Analysis, Fourth Edition,
*            Prentice-Hall, 2000.
*            Section 9.7.1, pp. 394-397.
SAMPLE sample 1 25
FORMAT (A8,A4,1X,F10.0,F12.0,F11.0,F13.0)
READ format (a8,a4,1x,f10.0,f12.0,f11.0,f13.0)
read (industry.shd) STATE1-STATE2 Q K L NF / SKIPLINE=1 FORMAT 
GENR LQ=LOG(Q)
GENR LK=LOG(K)
GENR LL=LOG(L)
state1-state2 q k l nf / skipline=1 format 
genr lq=log(q)
genr lk=log(k)
genr ll=log(l)

* Least Squares 
OLS LQ LK LL / COEF=BOLS
GEN1 SIG=SQRT($SIG2)
ols lq lk ll / coef=bols
gen1 sig=sqrt($sig2)

* Set starting values for the non-linear estimation
DIM BETA dim beta 5
GEN1 BETA:2=BOLS:3
GEN1 BETA:3=BOLS:1
GEN1 BETA:4=BOLS:2
GEN1 BETA:1=SIG
GEN1 BETA:5=1

GENR CONSTANT=0.5*LOG(2/$PI)
gen1 beta:2=bols:3
gen1 beta:3=bols:1
gen1 beta:4=bols:2
gen1 beta:1=sig
gen1 beta:5=1

genr constant=0.5*log(2/$pi)

* Define the regression function in a character string
ERROR: (LQ-(B0+BK*LK+BL*LL))
error: (lq-(b0+bk*lk+bl*ll))

* Specify the density function for the "half-normal" model.
* Use the LOGDEN option on the NL command.
NL nl 1 / NCOEF=5 LOGDEN START=BETA COEF=BNEW
EQ CONSTANT ncoef=5 logden start=beta coef=bnew
eq constant - 0.5*LOG(SIGMA**2) 0.5*log(sigma**2) - 0.5*([ERROR]/SIGMA)**2 0.5*([error]/sigma)**2 &
   + LOG(NCDF(-[ERROR]*LAMBDA/SIGMA))
END
log(ncdf(-[error]*lambda/sigma))
end

* Recover an estimate for sigma_v (reported as TEST VALUE).
TEST (SIGMA*SIGMA/(1+LAMBDA*LAMBDA))**0.5
test (sigma*sigma/(1+lambda*lambda))**0.5

* Recover an estimate for sigma_u
TEST (SIGMA*SIGMA*LAMBDA*LAMBDA/(1+LAMBDA*LAMBDA))**0.5
test (sigma*sigma*lambda*lambda/(1+lambda*lambda))**0.5

* Calculate the estimated inefficiencies
GEN1 SIGMA=BNEW:1
GEN1 LAMBDA=BNEW:5
GENR Z=(LQ-(BNEW:2+BNEW:3*LK+BNEW:4*LL))*LAMBDA/SIGMA
?DISTRIB Z / PDF=PDFZ
GENR U=SIGMA*LAMBDA/(1+LAMBDA*LAMBDA)*(PDFZ/(1-NCDF(Z))-Z)
FORMAT(1X,A8,A4,F12.4)
PRINT STATE1-STATE2 U / FORMAT
STOP
gen1 sigma=bnew:1
gen1 lambda=bnew:5
genr z=(lq-(bnew:2+bnew:3*lk+bnew:4*ll))*lambda/sigma
?distrib z / pdf=pdfz
genr u=sigma*lambda/(1+lambda*lambda)*(pdfz/(1-ncdf(z))-z)
format(1x,a8,a4,f12.4)
print state1-state2 u / format
stop

You can also look at Tim Coelli's excellent implementation here:

http://www.uq.edu.au/economics/cepa/frontier.htm

Some of his examples use SHAZAM.