\documentstyle[11pt,fullpage,psfig]{article}

\input info.tex

\frenchspacing

\begin{document}

\begin{center}\bf
Finger Exercises --- Due Tuesday, March 9, 1998
\end{center}

\begin{quote}\em
Please prepare answers for these exercises, to be turned in.  Your
grade will be based on how many questions you made a reasonably strong
effort to answer, {\bf not} how many questions you get right or
partially right.  There is no partial credit, but the grader may give
you additional written feedback on each question you attempt.

Feel free to discuss these exercises with each other and with me.  You
will get the most benefit from the grader's remarks, however, if the
work you turn in is your own.

\rm

This hw, like most material for this course, is posted on the World
Wide Web at URL \www{}; you can cut and paste data directly out of the
\TeX{} file if you wish.  Look for something under week2.

The following problems are taken from the book ``The Analysis of
Cross-Classified Categorical Data'' by Fienberg.
\end{quote}

\begin{enumerate}
\item Plackett presented the data below on a random sample of diabetic
  patients.  Fit appropriate loglinear models to these data and
  comment on the influence of family history of diabetes on the other
  two variables, and on the relationship between the other two
  variables.  Data in {\tt t312.dat}.
  \begin{center}
    \begin{tabular}{l l | r r | r r}
\hline
\multicolumn{2}{l|}{Family History of Diabetes} & \multicolumn{2}{c|}{Yes}
&\multicolumn{2}{c}{No} \\ \hline
\multicolumn{2}{l|}{Dependence on Insulin Injections} & Yes & No &
Yes & No \\\hline 
Age at Onset &$<45$  &   6 &  1 & 16 &  2 \\
             &$\geq 45$  &  6  & 36 &  8 & 48\\\hline
    \end{tabular}
  \end{center}

\item In a survey of a large American city, respondents were asked
  the question: ``Are the radio and TV networks doing a good job, just
  a fair job, or a poor job?''  Data for the responses it this
  question were broken down by the color of the respondent, and the
  question was asked in two separate years. Data in {\tt t316.dat}.
  \begin{center}
    \begin{tabular}{l l | r r r}
\hline
 & & \multicolumn{3}{c}{Response} \\
Year & Color & Good & Fair & Poor \\\hline
1959 & Black &  81 & 23 &  4 \\
     & White & 325 & 253 & 54 \\
1971 & Black & 224 & 144 & 24 \\
     & White &  600& 636& 158 \\ \hline
    \end{tabular}
  \end{center}
  \begin{enumerate}
  \item Which variables are explanatory?
  \item Which loglinear models provide an acceptable fit to the data?
  \item In your most parsimonious model that fits the data, look at
    the residuals and fitted values to decide if you like this model.
  \item Interpret your results.
  \end{enumerate}

\item Please select one of the previous problems and re-do it in SAS,
using whichever of PROC CATMOD, PROC GENMOD, PROC FREQ, (and possibly
other PROC's) you find useful.  Try to imitate as much of your SPLUS 
analysis in SAS as possible.   See back of this page for some hints
about how to learn about these procedures.

\end{enumerate}

\clearpage

{\bf Getting help in SAS}

After starting the interactive version of SAS by typing ``sas'' at the
UNIX prompt on Andrew, find the small horizontal toolbar labelled
{\sf Toolbox: PROGRAM EDITOR--Untitled} and click the help button on the
far right.

In the help window that pops up, you can 
\begin{itemize}

\item Click \ul{MODELING AND ANALYSIS TOOLS}, then \ul{Data Analysis} to
get a list of PROC's that you can get help on, including CATMOD, GENMOD
and FREQ.

\item Click \ul{SAMPLE PROGRAMS}, then \ul{SAS/STAT}, then e.g.
\ul{Documentation Examples from Proc} \ul{Catmod} (examples 4 and 5
illustrate fitting log-linear models) or \ul{Documentation Examples}
\ul{from Proc Genmod: 1} (look for the Poisson regression example), etc.,  
to get examples of how to set up SAS procedure files to use these commands.  

\item Graphics aren't all that easy to figure out in SAS.  Probably the
best thing to do is to try PROC INSIGHT.  An example of its use is given
at {\tt http://lib.stat.cmu.edu/\~{}giovanni/745/sas\_eda/sas\_eda.html}.
An example of using PROC INSIGHT to inspect residuals and so forth from
a standard linear regression model is given at
{\tt http://lib.stat.cmu.edu/\~{}giovanni/745/sas\_reg/sas\_reg.html}.

\end{itemize}

{\bf Running an analysis in SAS}

To run a SAS job, create the command file, let's say you call it 
{\tt bozo.sas}, in a text editor.  Now there are three things you can
do:
\begin{enumerate}

\item Say {\tt sas bozo.sas} at the UNIX command prompt, and then after
the command finishes running, look for newly created files in your 
directory, like {\tt bozo.log} and {\tt bozo.lst}.  

Or...

\item In the interactive windows version of SAS, find the small 
window labelled {\sf SAS: PROGRAM EDITOR--Untitled} and use the
File/Open... pulldown menu to read in your progam to the editor.  
Once it has been read in, find the small horizontal toolbar labelled 
{\sf Toolbox: PROGRAM EDITOR} again and click on the running man
in the middle of the toolbar to run the job.  The ``bozo.log'' file will 
appear in the {\sf SAS: LOG} window, and the ``bozo.lst'' 
file will appear in the {\sf SAS: OUTPUT} window.

{\bf Or...}

\clearpage

\item Even more interesting is to use PROC INSIGHT to do an entire
analysis.  You can get help on PROC INSIGHT by selecting \ul{MODELING
AND ANALYSIS TOOLS} and then \ul{Interactive Data Analysis}.  

To set this up you need a {\tt bozo.sas} file like this:
\begin{verbatim}
data accident;
input Cell Count Severity $ Eject $ Weight $ ;
datalines;
 1  350 Type1 Sev1 Ejct1  Wght1
 2  150 Type2 Sev1 Ejct1  Wght1
 3   60 Type1 Sev2 Ejct1  Wght1
 4  112 Type2 Sev2 Ejct1  Wght1
 5   26 Type1 Sev1 Ejct2  Wght1
 6   23 Type2 Sev1 Ejct2  Wght1
 7   19 Type1 Sev2 Ejct2  Wght1
 8   80 Type2 Sev2 Ejct2  Wght1
 9 1878 Type1 Sev1 Ejct1  Wght2
10 1022 Type2 Sev1 Ejct1  Wght2
11  148 Type1 Sev2 Ejct1  Wght2
12  404 Type2 Sev2 Ejct1  Wght2
13  111 Type1 Sev1 Ejct2  Wght2
14  161 Type2 Sev1 Ejct2  Wght2
15   22 Type1 Sev2 Ejct2  Wght2
16  265 Type2 Sev2 Ejct2  Wght2
;
proc insight data=accident;
run;
\end{verbatim}
When you run this in interactive SAS using method 2. above, a new window
will pop up with the data in a spreadsheet format.  
\begin{itemize}
\item You can use the {\sf Edit/Variables...} pulldown menu to recode 
variables if you wish, or use the {\sf Analyze} pulldown menu to make 
a variety of exploratory plots (e.g. scatter plots, box plots, and so forth.
\item More interestingly, you can use the {\sf Analyze/Fit(Y X)...} pulldown
menu to perform linear regressions, log-linear model fits, etc.  (after
selecting the Y and X variables in the dialog box for {\sf Analyze/Fit(Y
X)...}, be sure to click on the Method button and select {\sf Poisson}
for the response distribution and {\sf log} for the link function, from
the menu of radio buttons that appears.)
\end{itemize}

\end{enumerate}

To quit the interactive version of SAS, find the {\sf SAS: Session
Management} window (usually minimized, so you'll have to restore it from
its screen icon) and click on the ``Terminate'' button. 


\end{document}


