Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Looping through a vector with flexible dimension to calculate cdf values

    Hello,

    This is my first post on this forum and I am new to mata environment.

    I am building a non-linear model with categorical endogenous variable where the distribution of the underlying latent count variable that manifests as a categorical variable is hyper-poisson. I wrote a function in mata that returns the cdf of a hyper-poisson distributed variable. Inside this function, there is a loop that sums over the pdf values to calculate the cdf. The way the loop is written makes the function to accept only scalar. But later in another function that calculates the objective function to be optimized, the limits of integration is specified as a vector of the cdf values for each category. Not surprisingly, Stata returns the error message "3204 matrix found where scalar required" I would appreciate a way to write the cdf function in a way it accepts vectors or specify the limits of integration in such a way that it iterates through each observation in each of the categories.

    Attached is the function that computes the cdf of a hyper-poisson variate.

    Thanks,
    Attached Files
Working...
X