TSP is an econometrics/statistical package available in the Department
of Economics in two basic forms. First, the Department has a site
license for the PC version of TSP, allowing the package to be
placed on departmental computers for use by students and faculty.
A UNIX version TSP is also available on the Department Project
Vincent machines. The purpose of this document is to provide a
brief introduction on both how one can access TSP and the basic
TSP command. Additional information can be found in the TSP manuals
(available in the PC lab) and using TSP's online help system.
TSP ON UNIX
TSP ON THE PC
The PC version of TSP works fundamentally in the same manner
as the UNIX version. One difference is that, upon typing tsp
on the PC, you are given the option of either entering interactive
mode or providing TSP with a batch file already containing your
commands. You may also run batch files by typing
tsp myfile
as you would on the UNIX system. The output will be saved
to a file named myfile.out.
TSP COMMAND LANGUAGE BASICS
All TSP commands end with a semicolon (;). You can have more
than one command on a given line as long as they are separated
by semicolons. In interactive mode, a carriage return is the same
as a semicolon. Any information after a question mark (?) on a
given line is viewed as a comment. Here are some commonly required
steps in a TSP program and the corresponding commands.
AN EXAMPLE TSP PROGRAM
A scientist conducted experiments on corn yields. Various
plots received different levels of nitrogen and had different
seeding rates (plant population). The dependent variable for the
regression is corn yield while the independent variables are nitrogen
and plant population in thousands. There are 25 observations.
A variety of functional forms could be used to estimate this relationship.
Five possible functional forms are given below.
The log of zero is undefined so the analysis changes the sample size for creating the log variables, and runs regressions 4 and 5 with only 20 observations. An alternative would be to use a very small positive number close to zero. A copy of the computer code follows with comments in parentheses.
| freq n; | (sets the frequency to undated) |
| smpl 1 25; | (sets the sample size to 25) |
| read (file="corn2.dat") y pop n; | (reads the variables y,pop,n from the file corn2.dat) |
| genr n2=n**2; | (creates the variable n2) |
| genr pop2=pop**2; | (creates the variable pop2) |
| genr pn=pop*n; | (creates the variable n*pop) |
| print y n pop; | (prints the variables y,n,pop) |
| msd(corr) y n pop; | (computes interesting statistics) |
| olsq y C n pop; | (runs regression #1) |
| olsq y C n n2 pop pop2; | (runs regression #2) |
| olsq y C n n2 pop pop2 pn; | (runs regression #3) |
| smpl 6 25; | (changes the sample size to eliminate the zero observations) |
| genr ly = log(y); | (creates the variable log(y)) |
| genr ln = log(n); | (creates the variable log(n)) |
| genr lp = log(pop); | (creates the variable log(pop)) |
| olsq ly C ln lp; | (runs regression #4) |
| frml eq1 y = b1*(b2*n**(b3)+(1b2)*pop**(b3))**(1/b3); | (forms equation eq1) |
| param b1 5 b2 .3 b3 .2 ; | (sets parameters) |
| lsq eq1; | (estimates equation eq1) |
| stop; | stops |
Example Output
LINE 0 TSP 4.2A (09/09/92) DECStation
01/29/93 4:33 PM PAGE 1
TSP Version 4.2A
Copyright (C) 1992 TSP International
ALL RIGHTS RESERVED
In case of questions or problems, see your local TSP
consultant or send a description of the problem and the
associated TSP output to:
TSP International
P.O. Box 61015, Station A
Palo Alto, CA 94306
USA
PROGRAM
LINE ******************************************************************
| 1 freq n;
| 2 smpl 1 25;
| 3 read (file="corn2.dat") y pop n;
| 4 genr n2=n**2;
| 5 genr pop2=pop**2;
| 6 genr pn=pop*n;
| 7 print y n pop;
| 10 msd(corr) y n pop;
| 11 olsq y C n pop;
| 12 olsq y C n n2 pop pop2;
| 13 olsq y C n n2 pop pop2 pn;
| 14 ly = log(y);
| 15 smpl 6 25;
| 16 genr ln = log(n);
| 17 genr lp = log(pop);
| 18 olsq ly C ln lp;
| 19 frml eq1 y = b1*(b2*n**(b3)+(1b2)*pop**(b3))**(1/b3);
| 20 param b1 5 b2 .3 b3 .2 ;
| 21 lsq eq1;
| 22 stop;
EXECUTION
*******************************************************************************
Current sample: 1 to 25
LINE 7 TSP 4.2A (09/09/92) DECStation
01/29/93 4:33 PM PAGE 2
Y N POP
1 50.60000 0.00000 9.00000
2 54.20000 0.00000 12.00000
3 53.50000 0.00000 15.00000
4 48.50000 0.00000 18.00000
5 39.20000 0.00000 21.00000
6 78.70000 50.00000 9.00000
7 85.90000 50.00000 12.00000
8 88.80000 50.00000 15.00000
9 87.50000 50.00000 18.00000
10 81.90000 50.00000 21.00000
11 94.40000 100.00000 9.00000
12 105.30000 100.00000 12.00000
13 111.90000 100.00000 15.00000
14 114.20000 100.00000 18.00000
15 112.20000 100.00000 21.00000
16 97.80000 150.00000 9.00000
17 112.40000 150.00000 12.00000
18 122.60000 150.00000 15.00000
19 128.60001 150.00000 18.00000
20 130.30000 150.00000 21.00000
21 88.90000 200.00000 9.00000
22 107.10000 200.00000 12.00000
23 121.00000 200.00000 15.00000
24 130.60001 200.00000 18.00000
25 135.89999 200.00000 21.00000
RESULTS OF COVARIANCE PROCEDURE
*******************************
NUMBER OF OBSERVATIONS: 25
MEAN STD DEV MINIMUM MAXIMUM
Y 95.28000 28.54143 39.20000 135.89999
N 100.00000 72.16878 0.00000 200.00000
POP 15.00000 4.33013 9.00000 21.00000
SUM VARIANCE
Y 2382.00002 814.61335
N 2500.00000 5208.33333
POP 375.00000 18.75000
CORRELATION MATRIX
Y N POP
Y 1.00000
N 0.85354 1.00000
POP 0.22524 0.00000 1.0000
Equation 1
************
Method of estimation = Ordinary
Least Squares
Dependent variable: Y
Current sample: 1 to 25
Number of observations: 25
Mean of dependent variable = 95.2800 Adjusted Rsquared = .759201
Std. dev. of dependent var. = 28.5414 DurbinWatson statistic = 1.07241
Sum of squared residuals = 4315.47 Fstatistic (zero slopes) = 38.8342
Variance of residuals = 196.158 Schwarz Bayes. Info. Crit. = 5.53735
Std. error of regression = 14.0056 Log of likelihood function = 99.8620
Rsquared = .779268
Estimated Standard
Variable Coefficient Error tstatistic
C 39.2540 11.0280 3.55947
N .337560 .039614 8.52125
POP 1.48467 .660232 2.24871
Equation 2
************
Method of estimation = Ordinary
Least Squares
Dependent variable: Y
Current sample: 1 to 25
Number of observations: 25
Mean of dependent variable = 95.2800 Adjusted Rsquared = .918138
Std. dev. of dependent var. = 28.5414 DurbinWatson statistic = 1.20268
Sum of squared residuals = 1333.72 Fstatistic (zero slopes) = 68.2938
Variance of residuals = 66.6862 Schwarz Bayes. Info. Crit. = 4.62063
Std. error of regression = 8.16616 Log of likelihood function = 85.1841
Rsquared = .931781
Estimated Standard
Variable Coefficient Error tstatistic
C 22.3932 23.4332 .955618
N .830703 .081428 10.2017
N2 .246571E02 .390417E03 6.31559
POP 8.63229 3.27617 2.63487
POP2 .238254 .108449 2.19692
Equation 3
************
Method of estimation = Ordinary
Least Squares
Dependent variable: Y
Current sample: 1 to 25
Number of observations: 25
Mean of dependent variable = 95.2800
Std. dev. of dependent var. = 28.5414
Sum of squared residuals = .013029
Variance of residuals = .685752E03
Std. error of regression = .026187
Rsquared = .999999
Adjusted Rsquared = .999999
DurbinWatson statistic = 1.70018
Fstatistic (zero slopes) = .570198E+07
Schwarz Bayes. Info. Crit. = 6.78690
Log of likelihood function = 59.0194
Estimated Standard
Variable Coefficient Error tstatistic
C 14.1268 .079577 177.525
N .465503 .369809E03 1258.77
N2 .246571E02 .125197E05 1969.46
POP 6.19762 .010650 581.939
POP2 .238254 .347770E03 685.091
PN .024347 .174579E04 1394.59
Current sample: 6 to 25
Equation 4
************
Method of estimation = Ordinary
Least Squares
Dependent variable: LY
Current sample: 6 to 25
Number of observations: 20
Mean of dependent variable = 4.65721
Std. dev. of dependent var. = .171201
Sum of squared residuals = .098996
Variance of residuals = .582330E02
Std. error of regression = .076311
Rsquared = .822233
Adjusted Rsquared = .801319
DurbinWatson statistic = 1.35260
Fstatistic (zero slopes) = 39.3154
Schwarz Bayes. Info. Crit. = 4.85905
Log of likelihood function = 24.7053
Estimated Standard
Variable Coefficient Error tstatistic
C 2.76948 .217186 12.7516
LN .240777 .032775 7.34635
LP .283115 .057010 4.96607
*******************************************************************************
NONLINEAR LEAST SQUARES
***********************
EQUATIONS: EQ1
Working space used: 643
STARTING VALUES
B1 B2 B3
VALUE 5.00000 0.30000 0.20000
F= 4.8027 FNEW= 4.3379 ISQZ= 0 STEP= 1.0000 CRIT= 12.803
F= 4.3379 FNEW= 4.1044 ISQZ= 0 STEP= 1.0000 CRIT= 6.3604
F= 4.1044 FNEW= 4.1036 ISQZ= 0 STEP= 1.0000 CRIT= 0.26400E01
F= 4.1036 FNEW= 4.1036 ISQZ= 0
STEP= 1.0000 CRIT= 0.11075E05
CONVERGENCE ACHIEVED AFTER 4 ITERATIONS
8 FUNCTION EVALUATIONS.
LOG OF LIKELIHOOD FUNCTION = 80.4943
NUMBER OF OBSERVATIONS = 20
Standard
Parameter Estimate Error tstatistic
B1 3.01798 1.05080 2.87209
B2 .474150 .369490 1.28326
B3 .236724 .751327 .315074
Standard Errors computed from quadratic form of analytic first
derivatives (Gauss)
Equation EQ1
***************
Dependent variable: Y
Mean of dependent variable = 106.800 Std. error of regression = 14.6881
Std. dev. of dependent var. = 17.9674 Rsquared = .845027
Sum of squared residuals = 3667.59 Adjusted Rsquared = .826795
Variance of residuals = 215.740
DurbinWatson statistic = .862494
*******************************************************************************
END OF OUTPUT.
MEMORY ALLOCATED (WORDS) : 1000000
MEMORY ACTUALLY REQUIRED : 2307 ( 0%)
CURRENT VARIABLE STORAGE : 1658