This function implements Levene's Test for equality of variance across groups. It can also be used to detect problems of heteroskedasticity in a series, e.g., the residuals of a regression. The calculation is as shown by the National Institue of Standards and Technology's Engineering Statistics Handbook; for more information please visit: http://www.itl.nist.gov/div898/handbook/ . The function levene(y, x, code, nbins) returns the (scalar) p-value. The y series is the variable you want to test for homogeneity. The x series gives the basis for dividing the y values into groups. The third argument is an integer code for the variant of the test: case 1: The mean is used as the measure of central tendency case 2: The median is used case 3: The "10 percent trimmed mean" is used, meaning the mean calculated from a sample restricted to the range from the 0.05 quantile to the 0.95 quantile If this argument is omitted, the median is used. The final argument gives the number of groups or bins to create. If it is omitted or given as zero a group is created for each distinct value of x, otherwise the y values are grouped corresponding to nbins equally sized ranges for the x series. Note that each group must contain at least two y values, and considerably more values per group are needed if the trimmed mean option is selected. For more information about this function or if you want to give me some advice or improvement, please do send me an e-mail to ... (Note by Sven in July 2017: The email address given by Marcos Larios Santa Rosa isn't working anymore. Marcos if you read this, please get back to the gretl team and update your contact information. Thanks.) (Additional note by the gretl team in October 2024: some error checks were added, and gretl 2020c or later is now required.)