next up previous
Next: About this document ...

Dęmi um notkun SAS ķ samvikagreiningu.

Gefin er tafla sem geymir žyngd, kyn og lengd 25 sķlda sem voru teknar saman ķ sżni įriš 1992.

Gera skal samvikagreiningu meš žessum gögnum (meš lengd og žyngd į log-kvarša). Finna skal, hvort lengd og žyngd eru ķ marktęku samhengi, hvort mešalžyngd er breytileg eftir kynjum og hvort lengd-žyngdarsambandiš er breytilegt eftir kynjum, fyrst skuršpunkturinn, žį hallinn og sķšast annašhvort.

SAS forrit sem nęgir til aš gefa žessar upplżsingar er eftirfarandi.

data;
input w k l;
lnw=log(w);
lnl=log(l);
cards;
166     1       28
165     0       28
59      1       21
271     1       33
178     0       29
67      0       22
312     1       36
257     0       33
38      1       18
91      1       23
210     1       31
256     1       33
163     1       28
128     0       26
122     0       26
223     1       31
287     1       33
61      0       22
102     1       25
60      0       21
53      0       20
66      0       22
149     0       27
165     0       28
74      1       22
run;
proc print;
run;
proc means;classes k;run;
proc glm;
        classes k;
        model lnw=k;
run;
proc glm;
        classes k;
        model lnw=lnl;
run;
proc glm;
        classes k;
        model lnw=k lnl k*lnl;
run;

Data skrefiš (data step) sér um innlestur og reiknar ķ leišinni logaritma af męlingunum (lengd-žyngdar sambönd er best aš mešhöndla į log-kvarša).

Proc print og proc means setningarnar eru einungis til žess aš sjį gögnin og passa upp į aš žau hafi fariš rétt inn.

Fyrsta glm skipunin er prófun į žvķ, hvort sé munur į mešalžyngd kynjanna.

Sś nęsta setur upp eitt lengd-žyngdarsamband.

Aš lokum er sett upp flókiš lķkan sem lżsir žyngd sem falli af kyni og lķnu ķ log-lengd auk lišar sem er lķna ķ lengd, breytileg eftir kynjum.

                                        The SAS System     14:09 Tuesday, November 16, 1999  13

                          OBS     W     K     L      LNW        LNL

                            1    166    1    28    5.11199    3.33220
                            2    165    0    28    5.10595    3.33220
                            3     59    1    21    4.07754    3.04452
                            4    271    1    33    5.60212    3.49651
                            5    178    0    29    5.18178    3.36730
                            6     67    0    22    4.20469    3.09104
                            7    312    1    36    5.74300    3.58352
                            8    257    0    33    5.54908    3.49651
                            9     38    1    18    3.63759    2.89037
                           10     91    1    23    4.51086    3.13549
                           11    210    1    31    5.34711    3.43399
                           12    256    1    33    5.54518    3.49651
                           13    163    1    28    5.09375    3.33220
                           14    128    0    26    4.85203    3.25810
                           15    122    0    26    4.80402    3.25810
                           16    223    1    31    5.40717    3.43399
                           17    287    1    33    5.65948    3.49651
                           18     61    0    22    4.11087    3.09104
                           19    102    1    25    4.62497    3.21888
                           20     60    0    21    4.09434    3.04452
                           21     53    0    20    3.97029    2.99573
                           22     66    0    22    4.18965    3.09104
                           23    149    0    27    5.00395    3.29584
                           24    165    0    28    5.10595    3.33220
                           25     74    1    22    4.30407    3.09104
                                         The SAS System     14:09 Tuesday, November 16, 1999  14

              K  N Obs  Variable   N          Mean       Std Dev       Minimum       Maximum
   -----------------------------------------------------------------------------------------
              0     12  W         12   122.5833333    63.4657507    53.0000000   257.0000000
                        L         12    25.3333333     3.9389277    20.0000000    33.0000000
                        LNW       12     4.6810505     0.5357052     3.9702919     5.5490761
                        LNL       12     3.2211354     0.1546107     2.9957323     3.4965076

              1     13  W         13   173.2307692    93.8146700    38.0000000   312.0000000
                        L         13    27.8461538     5.5953277    18.0000000    36.0000000
                        LNW       13     4.9742169     0.6780508     3.6375862     5.7430032
                        LNL       13     3.3065947     0.2129189     2.8903718     3.5835189
   -----------------------------------------------------------------------------------------
                                         The SAS System     14:09 Tuesday, November 16, 1999  15

                                General Linear Models Procedure
                                    Class Level Information

                                   Class    Levels    Values

                                   K             2    0 1


                            Number of observations in data set = 25
                                         The SAS System     14:09 Tuesday, November 16, 1999  16

                                General Linear Models Procedure

Dependent Variable: LNW

Source                  DF           Sum of Squares             Mean Square   F Value     Pr > F

Model                    1               0.53630651              0.53630651      1.42     0.2452

Error                   23               8.67381544              0.37712241

Corrected Total         24               9.21012195

                  R-Square                     C.V.                Root MSE             LNW Mean
                  0.058230                 12.70515              0.61410293           4.83349704


Source                  DF                Type I SS             Mean Square   F Value     Pr > F

K                        1               0.53630651              0.53630651      1.42     0.2452

Source                  DF              Type III SS             Mean Square   F Value     Pr > F

K                        1               0.53630651              0.53630651      1.42     0.2452

Hér mį sjį aš ekki er marktękur munur į mešalžyngd kynjanna.
                                         The SAS System     14:09 Tuesday, November 16, 1999  17

                                General Linear Models Procedure
                                    Class Level Information

                                   Class    Levels    Values

                                   K             2    0 1


                            Number of observations in data set = 25
                                         The SAS System     14:09 Tuesday, November 16, 1999  18

                                General Linear Models Procedure

Dependent Variable: LNW

Source                  DF           Sum of Squares             Mean Square   F Value     Pr > F

Model                    1               9.11410497              9.11410497   2183.20     0.0001

Error                   23               0.09601698              0.00417465

Corrected Total         24               9.21012195

                  R-Square                     C.V.                Root MSE             LNW Mean

                  0.989575                 1.336745              0.06461154           4.83349704


Source                  DF                Type I SS             Mean Square   F Value     Pr > F

LNL                      1               9.11410497              9.11410497   2183.20     0.0001

Source                  DF              Type III SS             Mean Square   F Value     Pr > F

LNL                      1               9.11410497              9.11410497   2183.20     0.0001


Lengd-žyngdarsambandiš ln(w)=alpha+beta ln(l) er hįmarktękt,
ž.e.a.s. H0: beta=0 er hafnaš.  Žetta er ekki sérlega įhugaverš
nślltilgįta.
                                         The SAS System     14:09 Tuesday, November 16, 1999  19

                                General Linear Models Procedure
                                    Class Level Information

                                   Class    Levels    Values

                                   K             2    0 1


                            Number of observations in data set = 25
                                         The SAS System     14:09 Tuesday, November 16, 1999  20

                                General Linear Models Procedure

Dependent Variable: LNW

Source                  DF           Sum of Squares             Mean Square   F Value     Pr > F

Model                    3               9.12841633              3.04280544    782.06     0.0001

Error                   21               0.08170561              0.00389074

Corrected Total         24               9.21012195

                  R-Square                     C.V.                Root MSE             LNW Mean

                  0.991129                 1.290491              0.06237582           4.83349704


Source                  DF                Type I SS             Mean Square   F Value     Pr > F

K                        1               0.53630651              0.53630651    137.84     0.0001
LNL                      1               8.57904383              8.57904383   2204.99     0.0001
LNL*K                    1               0.01306600              0.01306600      3.36     0.0811

Source                  DF              Type III SS             Mean Square   F Value     Pr > F

K                        1               0.01346145              0.01346145      3.46     0.0769
LNL                      1               7.75850721              7.75850721   1994.09     0.0001
LNL*K                    1               0.01306600              0.01306600      3.36     0.0811

Hér kemur ķ ljós fremur įhugaverš nišurstaša.  Ķ fyrsta lagi eru
K og K*LNL bįšar į mörkum žess aš vera marktękar breytur (P=0.0769 og
P=0.0811).

Ķ öšru lagi mį nś bera saman žetta lķkan viš lķkaniš aš ofan žar sem einungis
var stušst viš ln(l). Lķkaniš hér er meš SSE(F)=0.0817, df(F)=21 en
aš ofan fékkst SSE(R)=0.0960, df(R)=23.  Hér munar tveimur frķgrįšum
og viš fįum reiknaš F-gildi sem 1.8, sem er ekki marktękt
(F(0.95,2,21)=3.47). Žvķ er ekki marktękt betra aš vera meš breytilegan
halla og skuršpunkt heldur en eina fasta lķnu.


Hins vegar mį athuga, hvort er betra t.d. aš vera einungis meš
breytilegan skuršpunkt.  Aš ofan er bśiš aš śtskżra
SS=0.53630651+8.57904383 = 9.11535 žegar bśiš er aš taka
ln(l) og k bęši inn ķ lķkaniš (2 df vegna 2ja skuršpunkta og eins halla
mķnus mešaltališ) og žvķ er SSE=9.21012195-9.11535=0.09477195 meš 22 df. 
Hins vegar var SS=9.11410497 meš 1 df žegar ln(l) var eitt inni.
Munurinn vegna k er žvķ 9.11535- 9.11410497 = 0.00124503 og 
F er reiknaš sem
        (0.0012450/1)/(0.09477195/22)=0.2890096

Žetta er vitanlega frįleitt marktękt.  Auk žess aš reikna žetta
śt frį ofangreindum töflum mį einnig lįta SAS prófa žessa kenningu
beint meš žvķ aš setja hlutina inn ķ réttri röš:


        proc glm;
           classes k;
           model lnw=lnl k;
           run;

og fį eftirfarandi śtkomur:
                                         The SAS System    15:29 Thursday, November 18, 1999  20

                                General Linear Models Procedure

Dependent Variable: LNW

Source                  DF           Sum of Squares             Mean Square   F Value     Pr > F

Model                    2               9.11535033              4.55767517   1058.01     0.0001

Error                   22               0.09477161              0.00430780

Corrected Total         24               9.21012195

                  R-Square                     C.V.                Root MSE             LNW Mean

                  0.989710                 1.357895              0.06563384           4.83349704


Source                  DF                Type I SS             Mean Square   F Value     Pr > F

LNL                      1               9.11410497              9.11410497   2115.72     0.0001
K                        1               0.00124536              0.00124536      0.29     0.5962

Source                  DF              Type III SS             Mean Square   F Value     Pr > F

LNL                      1               8.57904383              8.57904383   1991.51     0.0001
K                        1               0.00124536              0.00124536      0.29     0.5962

Aš lokum mį kanna, hvort er betra aš vera meš breytilegan halla.

Ķ ljós kemur aš breytilegur halli og skuršpunktur eru ekki marktękir
hver fyrir sig.  Einungis kemur fram vottur af marktękni ef hvorutveggja
er sett inn ķ einu.  Hér er įstęša til žess aš reyna aš rżna
nįnar ķ gögnin žvķ innbyršis ósamręmi af žessu tagi gęti t.d. bent
til žess aš einhverjar męlingar vęru afbrigšilegar.
                                         The SAS System    15:29 Thursday, November 18, 1999  28

                                General Linear Models Procedure

Dependent Variable: LNW

Source                  DF           Sum of Squares             Mean Square   F Value     Pr > F

Model                    3               9.12841633              3.04280544    782.06     0.0001

Error                   21               0.08170561              0.00389074

Corrected Total         24               9.21012195

                  R-Square                     C.V.                Root MSE             LNW Mean

                  0.991129                 1.290491              0.06237582           4.83349704


Source                  DF                Type I SS             Mean Square   F Value     Pr > F

LNL                      1               9.11410497              9.11410497   2342.51     0.0001
LNL*K                    1               0.00084991              0.00084991      0.22     0.6450
K                        1               0.01346145              0.01346145      3.46     0.0769

Source                  DF              Type III SS             Mean Square   F Value     Pr > F

LNL                      1               7.75850721              7.75850721   1994.09     0.0001
LNL*K                    1               0.01306600              0.01306600      3.36     0.0811
K                        1               0.01346145              0.01346145      3.46     0.0769


                                                T for H0:        Pr > |T|       Std Error of
Parameter                      Estimate        Parameter=0                        Estimate

INTERCEPT                  -5.514627109 B           -19.68         0.0001         0.28017026
LNL                         3.172098435 B            37.51         0.0001         0.08456907
LNL*K     0                 0.271492161 B             1.83         0.0811         0.14815022
          1                 0.000000000 B              .            .              .
K         0                -0.896593864 B            -1.86         0.0769         0.48202123
          1                 0.000000000 B              .            .              .

NOTE: The X'X matrix has been found to be singular and a generalized inverse was used to solve
      the normal equations.   Estimates followed by the letter 'B' are biased, and are not
      unique estimators of the parameters.




Gunnar Stefansson 2000-11-14