[Gretl-users] about distribution function display

Allin Cottrell cottrell at wfu.edu
Mon Nov 9 20:46:36 EST 2009


On Sun, 8 Nov 2009, Dorian Litvine wrote:

> Do you know how to describe the « estimated logit distribution » of a
> binary variable (dependent)? which means presenting the distribution
> function 1-F(X) of the probability of observing a given value of the
> dependent binary variable according to the values of a polynomial
> variable (independent) ?

Following is a script I used in an introductory econometrics
course; you can adapt it to your case.  In this case KL6 (number
of children less than 6 years old) is a variable that takes on
values 0, 1, 2 and 3 in the dataset, and we're showing the
nonlinear relationship between the value of KL6 and the
probability that the dependent variable (LFP, labor force
participation for a given woman) equals 1.

<script>
open mroz87.gdt -q

# list of independent variables
list Xlist = KL6 WA WE MTR

# run probit
probit LFP 0 Xlist

# set variables other than KL6 to their sample means
matrix Xrow = { 1, 0, mean(WA), mean(WE), mean(MTR) }
# generate 4 rows
matrix X = Xrow | Xrow | Xrow | Xrow
# set KL6 values from 0 to 3
matrix Kcol = { 0, 1, 2, 3 }'
X[,2] = Kcol
# check X
print X

# compute Phi(X\beta)
matrix P = Kcol ~ cnorm(X*$coeff)
# give names to the columns of P (optional)
colnames(P, "KL6 P(LFP=1)")
print P
# and make a graph
g1 <- gnuplot 2 1 --matrix=P --suppress --with-lines
g1.show
</script>

This is a probit example, so we use the cnorm() function
(cumulative normal distribution).  Gretl CVS/snapshot has a
similar function, logistic(), for the logistic CDF, but if you
don't have the snapshot you can write it yourself:

function matrix my_logistic (matrix x)
  scalar m = rows(x)
  scalar n = cols(x)
  matrix ret = x
  loop i=1..m -q
    loop j=1..n -q
      ret[i,j] = 1 / (1 + exp(-x[i,j]))
    endloop
  endloop
  return ret
end function

Allin Cottrell



More information about the Gretl-users mailing list