In this paper we have developed a state space model for the HIV epidemic in homosexual populations which have been divided into subpopulations according to sexual activity levels. In this model, the stochastic dynamic system model is the stochastic model of the HIV epidemic in terms of the chain multinomial model whereas the observation model is a statistical model based on the observed AIDS incidences. This model is applied to the San Francisco homosexual population for estimating the numbers of susceptible people, infective people and AIDS cases and for estimating the probabilities of HIV transmission from infective people to susceptible people given sexual contacts. The results show that the estimated numbers of AIDS incidence trace closely the observed numbers indicating the usefulness of the model. It is observed that the estimated numbers of latent people show multimodal curves and that HIV infection takes place during the primary stage and very late stage. The results have further shown that there are significant differences between the observed AIDS incidences and the estimates by the embedded deterministic model. These results indicate that using the embedded deterministic model to estimate the HIV-infected people and to predict future AIDS cases can be very misleading in some cases.