UCLA Academic Technology Services HomeServicesClassesContactJobs
Help the Stat Consulting Group by giving a gift             
Loading

Stata Textbook Examples
Design and Analysis by Geoffrey Keppel
Chapter 7: Analysis of Trend

Version info: Code for this page was tested in Stata 12.

In this chapter, Keppel shows how to do trend analysis. Let's start by running the overall anova as shown in table 7-1 on page 143.
use http://www.ats.ucla.edu/stat/stata/examples/da/chap7, clear
On page 145, Keppel shows a test of linear trend, and a test of quadratic trend on page 148, and a test of cubic trend on page 150. We create three variables acomp1, acomp2 and acomp3 to test for these three trend components. The variable acomp1 contains the coefficients for linear trend, and acomp2 has the coefficients for quadratic trend, and acomp3 has the coefficients for cubic trend.
generate acomp1=a
recode acomp1 1=-3 2=-1 3= 1 4= 3
generate acomp2=a
recode acomp2 1= 1 2=-1 3=-1 4= 1
generate acomp3=a
recode acomp3 1=-1 2= 3 3=-3 4= 1
Now we enter the variables acomp1, acomp2 and acomp3 into the anova command as continuous variables.
anova numcorr c.acomp1 c.acomp2 c.acomp3

                          Number of obs =      80     R-squared     =  0.2973
                           Root MSE      = 4.50424     Adj R-squared =  0.2695

                  Source |  Partial SS    df       MS           F     Prob > F
              -----------+----------------------------------------------------
                   Model |      652.30     3  217.433333      10.72     0.0000
                         |
                  acomp1 |      256.00     1      256.00      12.62     0.0007
                  acomp2 |      396.05     1      396.05      19.52     0.0000
                  acomp3 |         .25     1         .25       0.01     0.9119
                         |
                Residual |     1541.90    76  20.2881579   
              -----------+----------------------------------------------------
                   Total |     2194.20    79  27.7746835   

How to cite this page

Report an error on this page or leave a comment

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.