Automorphisms of Generic Abelian Varieties Automorphism groups of elliptic curves are very well understood. Of course, every elliptic curve has the automorphism $[-1]$ of order $2$. If we are over a (algebraically closed) field, this is the only non-trivial automorphism iff the $j$-invariant of our elliptic curve is neither $0$ nor $1728$. Over $\mathbb{C}$ the only other possibilities for automorphism groups are $\mathbb{Z}/4$ and $\mathbb{Z}/6$ occuring for $E = \mathbb{C}/\Lambda$ where $\Lambda$ is the square lattice or the "honeycomb" lattice respectively. 
In particular, the generic elliptic curve has automorphism group $\mathbb{Z}/2$, i.e. the locus of elliptic curves with bigger automorphism group in the moduli space of elliptic curves has codimension bigger than $0$. 
I am interested in the analogous question for abelian varieties. To force all the automorphism groups to be finite, it seems sensible to consider (principally) polarized abelian varieties. 

Let $\mathcal{A}_g$ be the moduli space of (principally) polarized complex abelian varieties of dimension $g$. What is the codimension of the locus of such varieties with automorphism group bigger than $\mathbb{Z}/2$ ?

Likewise, one can ask the same question not about arbitrary principally polarized abelian varieties, but such equipped with an endomorphism and level structure. So, in addition to the polarization on our (complex) abelian variety $A$ we also want a ring homomorphism $\mathcal{O}_F \to End(A)$ (for a fixed, say, quadratic imaginary field $F$), compatible with the Rosatti involution, and a level structure (plus some determinant/trace-condition). For a generic such $A$, its automorphism group may contain now $\mathcal{O}_F^\times$, depending on the level structure.

Let $Sh_g$ be the moduli space of such complex abelian varieties with PEL-structure (with the choices of $F$ and level implicit) of dimension $g$. Let $G$ be the smallest automorphism group of a point in $Sh_g$. What is the codimension of the locus of points of $Sh_g$ having automorphism group bigger than $G$?

 A: I will answer the first formulation of the question: As ulrich said, the answer is that the codimension is $g-1$, given by $\mathcal{A}_{g-1}\times X(1)$ mapping quasi-finitely to $\mathcal{A}_g$. 
To see this, let us work in Siegel space $\mathbb{H}_g$ with $Sp_{2g}(\mathbb{R})$ acting in the usual way. Having an extra automorphism is equivalent to being a stacky point in $\mathcal{A}_g$, which means that in $\mathbb{H}_g$ you are fixed by an element $t\in SP_{2g}(\mathbb{Z})$. It is easy to see that $t$ must have finite order. We will prove that for any finite order element $t$, the fixed set of $t$ in $\mathbb{H}_g$ is codimension at least $g-1$. 
To see this, first note that the claim is invariant under conjugating $t$, as this simply translates its fixed set. $t$ generates a finite, hence compact group. Thus we can conjugate $t$ inside of the standard maximal compact group $U(g)$. Moreover, we can further conjugate $t$ to lie in the standard maximal torus $T$ in $U(g)$, that is the diagonal matrices whose elements have unit norm. Thus we can write $$t=D(t_1,t_2,\dots,t_n)$$ where each $t_i$ is a root of unity. 
Now the fixed set of $t$ is easiest to see in the bounded model $B_g$ - which is biholomorphic to $\mathbb{H}_g$ in a $Sp_{2g}(\mathbb{R})$ equivaraint way so we are free to compute there instead.
In this model, $t$ multiplies $z_{ij}$ by $t_it_j$. Thus the fixed set is those matrices $Z$ that have non-zero entry $z_{ij}$ precisely when $t_it_j=1$. 
The problem is now purely a combinatorial one of trying to maximize the number of un-ordered pairs $i,j$ such that $t_it_j=1$. It is almost immediate to see that we may as well change all the  $t_i$'s that aren't $1$ to $-1$ and this will in fact increase the dimension of the fixed set. If we have $a$ 1's and $g-a$ -1's then we get a fixed locus of codimension $a(g-a)$ which is minimized when $a=1$ or $a=g-1$ (which are equivalent of course as $t$ and $-t$ give the same fixed set. This completes the proof.
It seems likely to me that by looking for which elements in $Sp_{2g}(\mathbb{Z})$ are conjugate to $t$ above one should be able to prove that $\mathcal{A}_{g-1}\times X(1)$ gives the unique component of maximal codimension, but I've not gone through and tried to do this.
Comment: A similar analysis should work for your second question, but I don't offhand know the uniformizing spaces.
