I want to calculate the AIC for a phylogeny that I inferred via maximum likelihood. To calculate the AIC I need to know the number of parameters in the model. But how do I determine this?
The number of parameters depends both on the number of taxa and model of sequence evolution. The topology is not typically considered a parameter in the usual sense of statistical inference (as it is the a priori specified topology the likelihood was calculated on).
So, for example, if you infer a tree from nucleotide data for 25 sequences under the General Time Reversible (GTR) model with gamma distributed among-site rate heterogeneity and empirical stationary frequencies (this is commonly called GTR+F+G), then you would have 56 parameters with the following breakdown: 2n - 3 = 47 branch lengths (where n = 25, the number of tips), 3 frequencies (because these sum to 1, once three are known the other is automatically known, so we only count 3 estimated parameters), 5 substitution rates (there are actually 6 substitution parameters in GTR, but it is typical to set one, usually G > C, to 1, and estimate the others relative to this, hence only 5 estimated) and 1 alpha parameter for the shape of the gamma distribution of rates (gamma distributions actually have two parameters, alpha and beta, but for phylogenetics we usually constrain them to be equal).
In total, this gives 47 branch lengths and 3 + 5 + 1 = 9 model parameters, and 47 + 9 = 56