% Options for packages loaded elsewhere
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
\PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor}
%
\documentclass[
  letterpaper,
  DIV=11,
  numbers=noendperiod]{scrartcl}
\usepackage{xcolor}
\usepackage{amsmath,amssymb}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
\usepackage{iftex}
\ifPDFTeX
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
  \usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
  \usepackage{unicode-math} % this also loads fontspec
  \defaultfontfeatures{Scale=MatchLowercase}
  \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
\usepackage{lmodern}
\ifPDFTeX\else
  % xetex/luatex font selection
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
  \usepackage[]{microtype}
  \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
  \IfFileExists{parskip.sty}{%
    \usepackage{parskip}
  }{% else
    \setlength{\parindent}{0pt}
    \setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
  \KOMAoptions{parskip=half}}
\makeatother
% Make \paragraph and \subparagraph free-standing
\makeatletter
\ifx\paragraph\undefined\else
  \let\oldparagraph\paragraph
  \renewcommand{\paragraph}{
    \@ifstar
      \xxxParagraphStar
      \xxxParagraphNoStar
  }
  \newcommand{\xxxParagraphStar}[1]{\oldparagraph*{#1}\mbox{}}
  \newcommand{\xxxParagraphNoStar}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
  \let\oldsubparagraph\subparagraph
  \renewcommand{\subparagraph}{
    \@ifstar
      \xxxSubParagraphStar
      \xxxSubParagraphNoStar
  }
  \newcommand{\xxxSubParagraphStar}[1]{\oldsubparagraph*{#1}\mbox{}}
  \newcommand{\xxxSubParagraphNoStar}[1]{\oldsubparagraph{#1}\mbox{}}
\fi
\makeatother

\usepackage{color}
\usepackage{fancyvrb}
\newcommand{\VerbBar}{|}
\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\usepackage{framed}
\definecolor{shadecolor}{RGB}{241,243,245}
\newenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}}
\newcommand{\AlertTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.40,0.45,0.13}{#1}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\BuiltInTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}}
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{#1}}
\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{\textbf{#1}}}
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\ExtensionTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.28,0.35,0.67}{#1}}
\newcommand{\ImportTok}[1]{\textcolor[rgb]{0.00,0.46,0.62}{#1}}
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{\textbf{#1}}}
\newcommand{\NormalTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\RegionMarkerTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.07,0.07,0.07}{#1}}
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}}

\usepackage{longtable,booktabs,array}
\newcounter{none} % for unnumbered tables
\usepackage{calc} % for calculating minipage widths
% Correct order of tables after \paragraph or \subparagraph
\usepackage{etoolbox}
\makeatletter
\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}
\makeatother
% Allow footnotes in longtable head/foot
\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
\makesavenoteenv{longtable}
\usepackage{graphicx}
\makeatletter
\newsavebox\pandoc@box
\newcommand*\pandocbounded[1]{% scales image to fit in text height/width
  \sbox\pandoc@box{#1}%
  \Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
  \Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
  \ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi% select the smaller of both
  \ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}%
  \else\usebox{\pandoc@box}%
  \fi%
}
% Set default figure placement to htbp
\def\fps@figure{htbp}
\makeatother





\setlength{\emergencystretch}{3em} % prevent overfull lines

\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}



 


\usepackage{booktabs}
\usepackage{caption}
\usepackage{longtable}
\usepackage{colortbl}
\usepackage{array}
\usepackage{anyfontsize}
\usepackage{multirow}
\KOMAoption{captions}{tableheading}
\makeatletter
\@ifpackageloaded{caption}{}{\usepackage{caption}}
\AtBeginDocument{%
\ifdefined\contentsname
  \renewcommand*\contentsname{Table of contents}
\else
  \newcommand\contentsname{Table of contents}
\fi
\ifdefined\listfigurename
  \renewcommand*\listfigurename{List of Figures}
\else
  \newcommand\listfigurename{List of Figures}
\fi
\ifdefined\listtablename
  \renewcommand*\listtablename{List of Tables}
\else
  \newcommand\listtablename{List of Tables}
\fi
\ifdefined\figurename
  \renewcommand*\figurename{Figure}
\else
  \newcommand\figurename{Figure}
\fi
\ifdefined\tablename
  \renewcommand*\tablename{Table}
\else
  \newcommand\tablename{Table}
\fi
}
\@ifpackageloaded{float}{}{\usepackage{float}}
\floatstyle{ruled}
\@ifundefined{c@chapter}{\newfloat{codelisting}{h}{lop}}{\newfloat{codelisting}{h}{lop}[chapter]}
\floatname{codelisting}{Listing}
\newcommand*\listoflistings{\listof{codelisting}{List of Listings}}
\makeatother
\makeatletter
\makeatother
\makeatletter
\@ifpackageloaded{caption}{}{\usepackage{caption}}
\@ifpackageloaded{subcaption}{}{\usepackage{subcaption}}
\makeatother
\usepackage{bookmark}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\urlstyle{same}
\hypersetup{
  pdftitle={Problem Set 4},
  colorlinks=true,
  linkcolor={blue},
  filecolor={Maroon},
  citecolor={Blue},
  urlcolor={Blue},
  pdfcreator={LaTeX via pandoc}}


\title{Problem Set 4}
\author{}
\date{}
\begin{document}
\maketitle


\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\item
  \textbf{Cancer and Group Therapy II}. Researchers randomly assigned
  metastatic breast cancer patients to either a control group or a group
  that received weekly 90-minute sessions of group therapy and
  self-hypnosis. The group therapy involved discussion and support for
  coping with the disease. The goal of the experiment was to see whether
  the latter treatment improved the patients' quality of life at the
  time, but a followup study on these patients collected data on the
  number of months of survival after the beginning of the
  study\footnote{Data from Q 4.31 in \emph{Statistical Sleuth}.}.

  You can access the data from this study using the following code.

\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{library}\NormalTok{(tidyverse)}
\NormalTok{cancer }\OtherTok{\textless{}{-}} \FunctionTok{read.csv}\NormalTok{(}\StringTok{"https://stat158.berkeley.edu/spring{-}2026/data/breast{-}cancer/breast{-}cancer.csv"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}

  \texttt{GROUP} is the original group assigned to the subject.
  \texttt{SURVIVAL} is the survival time in months from the beginning of
  the study. At the time the survival data was collected (10 years
  later), some subjects were still alive. They are flagged in the
  \texttt{CENSOR} column. Data (in this case survival time) that can
  only be known up to some bound is called \emph{censored}.

  \begin{enumerate}
  \def\labelenumii{\alph{enumii}.}
  \tightlist
  \item
    The parameter of central interest to researchers is the \(ATE\).
    What is the point estimate of this parameter using this data?
  \item
    Form a 95\% confidence interval associated the point estimate using
    the \(t\) distribution. As before use the pooled estimate of the
    standard deviation\footnote{In R, you can do this either ``by hand''
      using the point estimate plus and minus a value of \texttt{qt()}
      times your estimate of the SE. You can also return to the last
      time you saw this dataset, in a testing framework. The object
      created by \texttt{t.test()} has bundled with it the associated
      confidence interval.}.
  \item
    Form a 95\% CI using RBI and the constant-effect assumption.
  \item
    Methods b. and c.~rely upon different assumptions. Describe what
    they are and which seem more realistic in this particular setting.
  \end{enumerate}
\end{enumerate}

\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\setcounter{enumi}{1}
\item
  \textbf{Confident in your confidence intervals?} In lecture we formed
  a randomization-based confidence interval for the difference in mean
  response between the \(X=11\) group and the \(X=73\) group in the
  anchoring experiment. Your goal for this exercise is to use simulation
  to check the coverage of your interval and evaluate the consequences
  of using the constant effect assumption when it is violated.

  This simulation requires knowing the value of the true parameter,
  \(ATE\), so you'll be playing this question as an all knowing god with
  all potential outcomes at your fingertips. You can find two full
  schedules of potential outcomes at the following links.

\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{godlikeA }\OtherTok{\textless{}{-}} \FunctionTok{read.csv}\NormalTok{(}\StringTok{"https://stat158.berkeley.edu/spring{-}2026/data/anchoring/godlike\_schedule\_A.csv"}\NormalTok{)}
\NormalTok{godlikeB }\OtherTok{\textless{}{-}} \FunctionTok{read.csv}\NormalTok{(}\StringTok{"https://stat158.berkeley.edu/spring{-}2026/data/anchoring/godlike\_schedule\_B.csv"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}

  Schedule A represents a world with constant effects: the individual
  treatment effect for each unit is the same. Schedule B represents a
  world with variable effects: each unit has a different individual
  treatment effect.

  \begin{enumerate}
  \def\labelenumii{\alph{enumii}.}
  \tightlist
  \item
    For each god-like schedule A and B, calculate the true \(ATE\)
    parameters.
  \item
    For god-like schedule A, use simulation to create many original
    experiments and then for each construct a randomization-based CI
    with a constant effect assumption and evaluate whether it contains
    the true paramters. Select a \(1-\alpha\) confidence level to use
    that is between 60\% and 90\%. For A and B separately, report the
    proportion of confidence intervals that contain the parameter.
  \item
    Repeat b. but use god-like schedule B.
  \item
    Did your randomization-based CIs with the constant effect assumption
    from the previous two questions succeed in capturing the parameter
    with probability \(1-\alpha\)? If not, provide some intuition for
    why not.
  \end{enumerate}

  This is a challenging simulation to set up correctly. If you get stuck
  please consult the hints\footnote{The idea is to recreate the random
    process that leads to the create of the random confidence interval
    many times and check the proportion of those intervals that contain
    the parameter. In randomization-based inference, the only randomness
    comes from the assignments of units to treatment and control at the
    start of the original experiment, so that's were each one of your
    simulations begins.}\footnote{For each of settings A and B above,
    you will want to write a function. One approach is to write a
    function that:

    \begin{enumerate}
    \def\labelenumii{\arabic{enumii}.}
    \tightlist
    \item
      Randomly assigns each unit to one of the two groups.
    \item
      Sets the potential outcome that is \emph{not} observed to be
      \texttt{NA}. At this stage, you have the analog of an original
      experimental data set.
    \item
      Calculates \(\widehat{ATE}\).
    \item
      Uses \(\widehat{ATE}\) to impute the missing potential outcomes.
    \item
      Using this filled-in schedule, form a randomization-based
      confidence interval.
    \item
      Check whether the interval contains the true parameter and return
      that logical value.
    \end{enumerate}

    Then you can replicate this function many times and count the
    proportion of \texttt{TRUE}s to estimate the coverage probability.
    See \url{https://andrewpbray.github.io/designrbi} for functions to
    facilitate steps 1-5.}\footnote{This code may take awhile to run -
    you're simulating many randomization-based CIs - so start with small
    numbers of replicates while you're still testing your code. You can
    also take advantage of your computers ability to run multiple R
    sessions at the same time using the \texttt{future\_replicate()}
    function inside the \texttt{future.apply} package.}.
\end{enumerate}

\newpage{}

\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\setcounter{enumi}{2}
\item
  \textbf{Growing Herbs II}: Botanists studying optimal greenhouse
  conditions for a fast-growing herb ran a fully-crossed three-way
  factorial experiment. They manipulated light intensity (low, medium,
  or high), watering frequency (low, medium, or high), and soil type
  (sandy or loam). Each of the \(3 \times 3 \times 2 = 18\) treatment
  combinations was replicated twice, yielding \(n = 36\) plants. The
  response is shoot dry weight (grams) measured after four weeks.

  Their results from running a full three-way ANOVA model are shown in
  the table below.

\begin{verbatim}
                 Df Sum Sq Mean Sq F value   Pr(>F)    
light             2 190.54   95.27 135.084 1.45e-11 ***
water             2 131.53   65.76  93.246 3.17e-10 ***
soil              1  22.88   22.88  32.442 2.11e-05 ***
light:water       4  33.41    8.35  11.842 6.85e-05 ***
light:soil        2   4.98    2.49   3.533   0.0508 .  
water:soil        2   1.10    0.55   0.781   0.4727    
light:water:soil  4   6.34    1.59   2.248   0.1043    
Residuals        18  12.70    0.71                     
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
\end{verbatim}

  \begin{enumerate}
  \def\labelenumii{\alph{enumii}.}
  \item
    How many distinct null hypotheses are being tested in this ANOVA
    table?
  \item
    Consider a decision rule that rejects an individual null hypothesis
    when the p-value is less than or equal to \(\alpha = .05\). If we
    assume that the tests are independent, what is the probability of
    making at least one Type I error?
  \item
    If you wanted to control the strong family-wise error rate at
    \(\gamma = .05\) using a Bonferroni correction, what would be the
    new significance threshold for each individual test?
  \item
    How many of the tests in the ANOVA table would be considered
    statistically significant at the \(\alpha = .05\) level? How many
    would be considered statistically significant at the
    Bonferroni-corrected threshold you calculated in part c.?
  \item
    Consider the proof we went through in class showing that a decision
    rule that uses the Bonferroni correction keeps the family-wise error
    rate less than or equal to \(\gamma\). Under what scenario would
    this bound be tight? That is, when would the family-wise error rate
    actually equal \(\gamma\) when using the Bonferroni correction? Does
    this seem like a realistic scenario in practice? What does that tell
    you about the actual family-wise error rate when using the
    Bonferroni correction in practice?
  \end{enumerate}
\end{enumerate}

\newpage{}

\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\setcounter{enumi}{3}
\item
  \textbf{Babies Walking: Blocks}. Consider the Babies Walking study
  from lecture where babies were randomly assigned to one of four
  programs and the time it took for them to walk was recorded.

  \begin{enumerate}
  \def\labelenumii{\alph{enumii}.}
  \item
    Why would it be difficult to use \emph{parent ID} as a blocking
    factor in this study?
  \item
    List two factors that \emph{could} be used as blocking factors in
    this study. For each factor, why you would expect it to explain
    variation in walking time.
  \item
    Imagine that one of your blocking factors has five levels, allowing
    for a complete block design. The data frame below provides the id of
    each baby in the original study along with their correponding block.
    Fill in the program column with a random assignment of the four
    programs to the babies within each block.
  \end{enumerate}

  \begin{table}
  \fontsize{12.0pt}{14.0pt}\selectfont
  \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}rcc}
  \toprule
  id & block & program \\ 
  \midrule\addlinespace[2.5pt]
  1 & A & NA \\ 
  2 & A & NA \\ 
  3 & A & NA \\ 
  4 & A & NA \\ 
  5 & B & NA \\ 
  6 & B & NA \\ 
  7 & B & NA \\ 
  8 & B & NA \\ 
  9 & C & NA \\ 
  10 & C & NA \\ 
  11 & C & NA \\ 
  12 & C & NA \\ 
  13 & D & NA \\ 
  14 & D & NA \\ 
  15 & D & NA \\ 
  16 & D & NA \\ 
  17 & E & NA \\ 
  18 & E & NA \\ 
  19 & E & NA \\ 
  20 & E & NA \\ 
  \bottomrule
  \end{tabular*}
  \end{table}
\end{enumerate}

\newpage{}

\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\setcounter{enumi}{4}
\item
  \textbf{Blocking and Variance: Model-based}. In lecture we worked
  through the exact standard error of \(\widehat{ATE}\) from the
  Randomization-Based framework. Consider an analogous parametric
  framing using the following model:

  \[Y_i \overset{\text{iid}}{\sim} N(\mu_{j(i)}, \sigma^2_{j(i)})\]

  where there are \(J = 2\) groups of size \(n_1\) and \(n_2\), and
  \(j(i)\) is the treatment that unit \(i\) belongs to.

  \begin{enumerate}
  \def\labelenumii{\alph{enumii}.}
  \item
    What is the variance of \(\widehat{ATE}\) under this model?
  \item
    What guidance does this give us in making designs that maximize
    precision and power? Specifically comment on four quantities
    inspected in the lecture: the total number of units, the variances
    of the outcomes in each group, the balance of the design, and
    covariance between the outcomes in the two groups. Is there any
    difference in the guidance provided by this model-based framing
    compared to the randomization-based framing?
  \end{enumerate}
\end{enumerate}

\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\setcounter{enumi}{5}
\item
  \textbf{Blocking and Variance: Unequal Treatment Allocation}. In the
  GCB design from lecture, each block assigned exactly half its units to
  treatment and half to control. Suppose instead that block \(A\) (of
  size \(n_A\)) assigns \(n_{A1}\) units to treatment and
  \(n_{A0} = n_A - n_{A1}\) to control, and similarly block \(B\)
  assigns \(n_{B1}\) to treatment and \(n_{B0} = n_B - n_{B1}\) to
  control, where \(n_{A1}/n_A \neq n_{B1}/n_B\). For these calculations,
  use the (simpler) model-based framing from the previous question

  \begin{enumerate}
  \def\labelenumii{\alph{enumii}.}
  \item
    Is the estimator
    \(\widehat{ATE} = \frac{n_A}{n}\widehat{ATE}_A + \frac{n_B}{n}\widehat{ATE}_B\)
    still unbiased for the overall ATE? Justify your answer.
  \item
    Write out the full expression for \(SE(\widehat{ATE})\),
    substituting in the CR{[}1{]} formula for each block-level SE
    (treating each block as its own completely randomized experiment
    with potentially unequal group sizes).
  \item
    Suppose \(\sigma_1^2 > \sigma_0^2\) within block \(A\). Based on the
    CR{[}1{]} SE formula, what allocation ratio \(n_{A1}/n_{A0}\)
    minimizes \(Var(\widehat{ATE}_A)\)? What does this suggest about how
    you should design the experiment when you have prior knowledge about
    within-block variance?
  \end{enumerate}
\end{enumerate}




\end{document}
