Changing variables names for quantileFit

Goals

One of the options that can be controlled with the qFitControl structure is what variable names are printed in the output table. This tutorial teaches how to change variable names using the qFit.varnames member. After this tutorials you should understand:

  • How to use the qFit.varnames member of the qFitControl structure

The qCtl.varnames member

As we previously saw, when data matrices are used as inputs into quantileFit GAUSS uses default variable names, $X01, X02, \ldots, X0K$.

We can specify our own variable names using the qCtl.varnames structure member


qCtl.varnames
String array, the variable names to be printed in the output table. String array length must equal the number of independent variables or the default variable names will be used.

Example

Consider our earlier example :

$$ln(wage) = \alpha + \beta_1 * age + \beta_2 * age^2 + \beta_3 * tenure$$

which, when estimated using data matrices for inputs, returns the following output:

Total observations:                                   28101
Number of variables: 3
VAR. / tau (in %) 5% 50% 95%
--------------------------------------------------- CONSTANT -0.7630 0.5112 0.0006 X01 0.1103 0.0656 0.1271 X02 -0.0017 -0.0010 -0.0016 X03 0.0356 0.0466 0.0196

To make the table more descriptive, we can add variable names to our table using the qFit.varnames member of the qFitControl structure.

To use the qFit.varnames member we must first declare an instance of the qFit.Control structure and fill it with default member values:

// Set up control structure
struct qFitControl qCtl;

// Fill control struct with defaults
qCtl = qFitControlCreate();

Next we specify our variable names :

// Add variable names
qCtl.varnames = "Age" $| "Age:Age" $| "Tenure";

Finally, we include our control structure as the final input when calling quantileFit :

// Create string with full path to dataset
dataset = getGAUSSHome() $+ "examples/regsmpl.dta";

// Load dependent variable
y = loadd(dataset, "ln_wage");

// Load the independent variables
x = loadd(dataset, "age + age:age + tenure");

// Estimate the model with matrix inputs
struct qFitOut qOut;
qOut = quantileFit(y, x, qCtl);

Our results now include the variable names we have specified:

Total observations:                                   28101
Number of variables: 3
VAR. / tau (in %) 5% 50% 95%
--------------------------------------------------- CONSTANT -0.7630 0.5112 0.0006 Age 0.1103 0.0656 0.1271 Age:Age -0.0017 -0.0010 -0.0016 Tenure 0.0356 0.0466 0.0196

Conclusion

Congratulations! After this tutorial you should know how to use the qFit.varnames member of the qFitControl structure to specify variable names used when printing results.

The next tutorial teaches how to change output printing options using the qFit.verbose member.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.