SOC 2011

Third Assignment

START WORKING ON IT AS SOON AS YOU CAN!

 

 

In this assignment you will be using LIMDEP. You will analyze a binary and a polytomous dependent variable and you will also see if the categories of the polytomy are ordered.

To use LIMDEP first you will have to prepare your data in SPSS.

Step 1.

Choose a dependent variable. You will end with two versions of it (unless it is a dichotomy).

If the chosen variable is interval or ratio

collapse it into a dichotomy and a trichotomy.

If the variable is ordinal

collapse it into a dichotomy and if it has more than 4 categories collapse some categories so that

you have a second variable with 4 categories or less.

If the variable is nominal and polytomous

create a dichotomy and if the polytomy has more than 4 categories collapse some categories so

that you have a second variable with 4 categories or less.

If the variable is a dichotomy

you will need another variable with at least three categories as well. Either way you will have two

dependent variables: a dichotomy and a polytomy (ordered or unordered).

Make sure that both dependent variables are scored starting at 0.

Choose at least 4 independent variables.

Select only those cases that have no missing value on any of the dependent or independent variables.

Format the variables you chose to a uniform f8.2 format. This means that each variable will take up 8 columns and there will be two columns after the decimal.

To check the recodes run frequencies on all the variables that you recoded. Write down the sample size on a piece of paper. You will need this information later for LIMDEP.

Save the data as an ASCII file using the WRITE OUTFILE command. Make sure you put EXECUTE after it. Write down the order of the variables as they appear on the WRITE command (you will need this information too later for LIMDEP).

Example:

GET

FILE='c:\My Documents\Class\SOC206\DATA\gss91.sav'.

EXECUTE .

*Recoding church attendance into a dichotomy and a trichotomy.

recode attend (0 thru 3=0) (4 thru 8=1) into att2.

recode attend (0 thru 2=0) (3 thru 5=1) (6 thru 8=2) into att3.

*Recoding missing data into system missing.

recode educ (97 thru hi=sysmis).

recode age (98 thru hi=sysmis).

recode prestg80 (0=sysmis).

*Creating a uniform format for the variables to be saved.

format att2 att3 educ sex age prestg80 (f8.2).

*Checking on the recodes and remembering the sample size.

freq att2 att3.

*Writing the variables into an ASCII file.

write outfile 'c:\My Documents\Class\SOC206\DATA\h4.dat' / att2 att3 educ sex age prestg80.

execute.

 

 

Step 2.

Now you take your ASCII data file and analyze it with LIMDEP. What you need to do is to

  1. Run a binary (dichotomous) logit for your dichotomous dependent variable and all the independent variables. Interpret the model.
  1. To show what the Restricted Log-likelihood is, first run the model with all the slope fixed to 0. You will find that LIMDEP does not acknowledge the constraints in the degrees of freedom displayed. In this particular model the degrees of freedom should read 0. Each time you run a model with constraints you have to calculate the degrees of freedom yourself. The general formula is K*(C-1)-R, where K=the number of independent variables, C= the number of categories of the dependent variable and R is the number of restrictions/constraints imposed on the coefficients. In other words, the degrees of freedom is the number of slopes freely estimated. (E.g. if two slopes are constrained to be eaqual that means that only one is freely estimated, the other is not.)
  2. Then run the unconstrained model.
  3. Look at the coefficients and calculate the fit statistics (McFadden�s  pseudo-R2s and the pseudo-R2 you find in your textbook  on p.313.). Interpret the findings.
  4. Calculate how much the probability (as opposed to the log-odds) changes for one unit change in one of the independent variables for a particular person. By 'particular person,' I mean either a person who has a certain, theoretically important combination of values on the other independent variables (e.g. one may look at the effect of age for a college educated male, with a highly prestigious (PRESTG80=85) occupation), or it can be the average person (e.g. the person with average education and average prestige, though you would have to pick the persons gender, since the average gender is meaningless).
  1. Impose the following restriction on the model. Test if two coefficients are the same. Try to make sure that the two variables have roughly the same metric (e.g. both are measured in dollars, years, or both are dummy variables). What are your degrees of freedom? How does Chi-squared change? In some cases you will find no Chi-squared statistic. This happens when your log-likelihood is a larger negative number than the restricted log-likelihood. You do not get a Chi-squared because it would have to be negative and Chi-squared is never negative. When this happens LIMDEP tells you that the fit of this constrained model is so poor that making these assumptions about the model is worse than not knowing anything about the independent variables.
  2. Run a multinomial logit for the other dependent variables.
  1. Look at the coefficients, the model chi-squared and calculate the fit statistics. Interpret the findings.
  2. Calculate how much the probability (as opposed to the log-odds) changes for one unit change in one of the variables for a particular person. Do this for two contrasts.
  1. Impose two restrictions on the model.
  1. The first restriction is that coefficients belonging to the same independent variable (but not the intercepts) are the same across contrasts. (This is a test of irrelevant alternatives. If the restriction does not worsen the fit significantly, the categories can be collapsed, the distinction between them is irrelevant from the perspective of this particular model.) Is this a reasonable assumption?
  2. Then make this restriction only for the coefficients that you think should have the same effect across contrasts. Interpret the findings. In Both cases you have to compare the unrestricted and the restricted model and see how much the Chi-squared diminishes.
  1. Run an ordered logit analysis of the polytomous dependent variables.
  1. Compare the Chi-squared and the degrees of freedom with the unrestricted multinomial model.
  2. Look at the coefficients and calculate the fit statistics. Interpret the findings.
  3. Calculate, how much the probability (as opposed to the log-odds) changes for one unit change in one of the independent variables for a particular person.

To do all this first you have to create a syntax (command) file. You may use your editor for this purpose, because LIMDEP�s editor is quite antediluvian. Make sure you save the file as a text (and not as a Word or WP document file). You may also use the editor in SPSS.

LIMDEP command syntax is as follows. Each command starts with a 'verb' , which is followed by specifications separated by a semicolon (SPSS has slashes /). Each command ends in a $ (a period in SPSS).

VERB;specification; specification;specification$

No command line can be longer than 60 characters, but a command can have any number of lines.

 

First you need to READ in the data (in SPSS the GET command serves a similar function).

Then you have to OPEN an output file (SPSS opens one for you automatically and asks you for a name only when you want to save it or exit the program.)

Then you have to tell LIMDEP to SKIP missing values in the analysis. (SPSS is smarter, it does it automatically.)

Then you have to get the descriptive statistics (DSTAT). (SPSS has the DESCRIPTIVES).

Then you run the binary logit with restrictions (LOGIT). The logit has a Left Hand Side (LHS) variable for the dependent variable and Right Hand Side variables for the independent variables. On the Right Hand Side there is always a special variable. It is called ONE and this is what needs to be included to get the intercept. Then there are the restrictions (RST). The restrictions list all coefficients, including the intercept (b0). The logic of the restrictions for the binary logit model: The coefficients are listed from b0 to bn, where n is the number of independent variables. If you have four independent variables you will have coefficients from b0 to b4.

After RST= you have to list all.

If they are all estimated freely (in which case you would not have to use this specification, because this is the default)

;RST=b0,b1,b2,b3,b4$

If the effect of the first and the third variables were to be the same

;RST=b0,b1,b2,b1,b4$

If the effect of the first variable were to be 2.5, and the fourth would have no effect

;RST=b0,2.5,b2,b3,0$

Then you run the multinomial logit (LOGIT). It has exactly the same syntax as the binary logit. (LIMDEP counts the number of categories the dependent variable has and 'decides' if it is a binary or a multinomial logit.)

Then impose the restrictions.

The logic of the restrictions for the multinomial logit model: The coefficients are listed from b0 to bn, where bn is the last coefficient. If you have four independent variables and three categories you will have coefficients from b0 to b9 standing for the 10 coefficients (2 for each independent variable plus two intercepts). After RST= you have to list all.

If they are all estimated freely (in which case you would not have to use this specification, because this is the default)

;RST= b0, b1,b2,b3,b4,b5,b6,b7,b8,b9$

If the effect of the first variable is the same for both contrasts:

;RST= b0, b1,b2,b3,b4,b5,b1,b7,b8,b9$

If you want the first variable to affect the first but not the second contrast:

; RST= b0, b1,b2,b3,b4,b5,0,b7,b8,b9$

Finally, run the ordered logit model (ORDERED). It has the same syntax as LOGIT, but it has to end with the specification

;LOGIT$

otherwise, it estimates an ordered probit. (It will say ordered probit on your output anyway.

 

To run LIMDEP, you have to get into LIMDEP. Once you click on the LIMDEP icon. To open a new command file click on File New and choose Text/Command Document.

Write the the command file. (You can also write the first draft of your command file in word processor and save it as a simple text file with the extension *.lim. Get into LIMDEP, and click on File Open.)

To run the commands in your file you have to highlight the lines, then click on Run Run Selection.

After you debugged the program, save it. Exit the program. Start over and run the clean command file.

EXAMPLE of a command file with annotation:

?This reads in the datafile. There are 1517 cases (records), 6 variables

?in file h4.dat, all six has f8.2 format and they have the names listed.

?Blanks in the end tells LIMDEP that the blanks are missing data

read; nrec=1517; nvar=6; file=h:\h4.dat; format=(6f8.2);

names(x1=att2, x2=att3, x3=educ, x4=sex, x5=age, x6=prestg80);

blanks $

?This opens an output file where the output is stored

open; output=outfile$

?This tells LIMDEP to skip the missing values in the estimation.

?Silly but true, LIMDEP does not do this by default.

skip$

?This gives the Descriptive STATistics just to check

?if you read the data right. RHS stands for Right Hand Side but

?here could simply stand for VARIABLES

dstat; rhs=att2, att3, educ, sex, age, prestg80$

?Here is the first logit. The Left Hand Side (LHS) of the equation is the

?dependent variable. The Right Hand Side (RHS) is where the independent

?variables are. This is the model assuming that none of the independent

?variables matters.

?We have restricted their effect to 0. There is still an intercept that

?LIMDEP needs to estimate. The intercept is obtained

?by including a special variable for the intercept. This is called: ONE.

? The Log-Likelihood function in this model is the same as the

?Restricted Log-Loglikelihood for all other models with the same

?dependent variable (and cases). The intercept is b0.

?On the RST command you have to put in as many 0s after b0 as many

?independent variables you have.

logit; lhs=att2; rhs=one, educ, sex, age, prestg80;

RST=b0,0,0,0,0$

?This is the unrestricted model

logit; lhs=att2; rhs=one, educ, sex, age, prestg80$

?This restricts the effect of education and age to the same value

logit; lhs=att2; rhs=one, educ, sex, age, prestg80;

RST=b0,b1,b2,b1,b4$

?This is the multinomial logit for the trichotomous dependent variable

?(att3)

logit; lhs=att3; rhs=one, educ, sex, age, prestg80$

?This is to show what happens when we assume that each variable has the

?same effect in each comparison. After RST I have b1 to b4 twice because

?I have 4 independent variables and two contrasts to estimate. NOTICE

? that the intercept is not constrained across contrasts. This is

?because while we assume that each independent variable has the same

?effect, we do not assume that the proportion of cases in each

?non-baseline response category (Y=1, Y=2 etc.) is the same. You have

?to adjust this part according to the number of independent variables

?you have and the number of contrasts you have to estimate. Remember

?the number of contrasts is k-1, where k is the number of categories the

?dependent variable has. The number of coefficients is (k-1)*(x+1) where

? x is the number of independent variables (and the +1 is for the

?constant). So it is b0,....,b(k-1)*(x+1)-1.

logit; lhs=att3; rhs=one, educ, sex, age, prestg80;

RST=b0,b1,b2,b3,b4,b5,b1,b2,b3,b4$

?I have restricted the effect of sex to be same for both contrasts

logit; lhs=att3; rhs=one, educ, sex, age, prestg80;

RST=b0,b1,b2,b3,b4,b5,b6,b2,b8,b9$

?Estimating ordered logit model. If you forget to end the command with

;logit, it will estimate an ordered probit rather than an ordered logit.

ordered; lhs=att3; rhs=one, educ, sex, age, prestg80;

logit$

 

____________________________________________________________

I will need to see how you did the calculations! Turn in your worksheets!

To help me read your output write above the results what you are testing.

____________________________________________________________