1. How do I get rid of a Stata variable so that I can redefine it?

Here are two ways to do this. In the first example, the variable x was created in error, and needs to be fixed:

```. generate x = y + 2
. generate x = y + z
r(110);

. drop x
. generate x = y + z
```
In the second example, we would like to subtract one from each value of x:
```. generate x = x - 1
r(110);

. replace x = x - 1

```
replace is the same as dropping a variable and then generating its replacement.
2. How do I re-save an updated data set?

If you already have created a Stata data set (suppose you have called it mydata), then Stata won't let you accidentally save anything else with the same name --- including a revised version of the same data set. To do this, you have to let Stata know that your request was no accident. The following example illustrates the problem and the solution.

```. save mydata
r(602);

. save mydata, replace
file mydata.dta saved
```
3. How do I fit the independence model in blogit?

Suppose that y and n contain the number of "successes" and the total number of trials, respectively, and that x contains the value of a (possible) predictor.

```. blogit y n x
```
fits the linear logistic model logit(pi) = a + bx, where pi=P(Y==1). To fit the same model, but without the term involving x, which implies that y and x are independent, use the command
```.blogit y n
```
4. What is the "linear probability model" and how do I fit it?

The linear logistic model is an additive model for the log-odds (or the logit of the probability):

logit(pi) = a +bx
By contrast, the linear probability model is an additive model for the probabilities themselves:
pi = a +bx
If the number of successes, the number of trials, and the predictor variable are denoted respectively by y, n, and x, the two models above are fit, respectively, using the Stata commands
```logistic regression:       . blogit y n x

linear probability:        . generate pihat = y / n
. regress pihat x

```
5. I'm having a bit of trouble getting the loglin macros from your webpage copied onto my Unix account.

(a) If you have already successfully copied the files, but the loglin commands don't seem to be active, skip this part and proceed to part (b).

Use a Web browser to copy the files to your Unix account.
Here are the steps using Netscape:

```   1. login to mach
2. start Netscape
3. visit http://www.stat.uchicago.edu/~thisted/courses/226
4. put your mouse on the link named "loglin.hlp", then hold the mouse button
down until a menu pops up.  Select the option to "Save this link as..."
5. save the link as "loglin.hlp" (all lower case letters).
```

Here are the steps using lynx ( a text-based browser ).
```
2. give the command
lynx http://www.stat.uchicago.edu/~thisted/courses/226
3. use the TAB key until the link named "loglin.hlp" is highlighted
4. type the lower-case letter "d"
Typically, the only option is "Save to Disk", which would be highlighted.
6. press the return key to save the contents of the link to your Unix
disk space.
7. You will then be asked to "Enter a filename:".
The program will actually suggest "loglin.hlp", so you can simply
hit the return key to select that filename.
9. Type "Q" to exit from lynx.
```
(b) If you successfully copied the files, but the loglin commands don't seem to be active:

The original names for the files were LOGLIN.ADO and LOGLIN.HLP; unfortunately, Stata looks for files with names all in lower case (loglin.ado and loglin.hlp) in Unix versions of Stata.

If the files are in your Unix directory, the commands

```       mv LOGLIN.ADO loglin.ado
mv LOGLIN.HLP loglin.hlp
```
will fix the situation.
6. loglin tells me that it can't fit models with more than four variables. But the homework contains a problem with five variables? How can it be done?

Why, you might ask, can't loglin handle more than four variables? The reason is not very appealing: variable names in Stata are limited to eight characters in length. A five-way interaction would create variables of the form ABCDE22232 (which is obviously too long).

Fortunately, something (easy) can be done to circumvent the problem. First, create a new variable that incorporates two of your underlying variables. In Agresti's Table 7.17 on page 255, for instance, you could combine the four levels of sex and IQ. Assuming that sex and IQ are each coded using 0 and 1:

```       generate sexiq = 2*sex + IQ
```
You can then run loglin with sexiq as one of the variables in loglin. If sexiq is the last variable on the list (so that loglin assigns it "D"), you should think of every term with D in it as really containin DE (that is, sex and IQ and their interaction).

At a later stage in the analysis, when things are a bit simpler, sex and IQ can be split apart, or can be combined simply with the dummy variables for the other interactions already generated by loglin.