Error message: G0505: Invalid structure redefinition 'glmOut'

Hi All,

I am struggling with the following issue:

I want to use the glm function within a procedure to estimate a binary outcome variable (logit function).

I am using the following code:

proc(1) = est2(x_1, y_1, d_1, z_1);
local vnam, m, b, stb, vc, stderr, sigma, cx, rsq, resid, dwstat, cov_2_1, cov_2_2, beta_est2_2, y_hat_logit_2_2, d_hat_structure, d_hat_logit_2_1, res_est2;

    new; cls;

    // prepare datasets as under OLS
    cov_2_1 = z_1 ~ x_1[.,4:6];

    // create glm structure
    struct glmOut d_hat_structure;
    d_hat_structure = glm(d_1,cov_2_1,"binomial");

before performing the step with struct glmOut d_hat_structure;, I get the error: 'Error message: G0505: Invalid structure redefinition 'glmOut''.

I have tried to clear the structure with the command new;, but unfortunately, it did not work. Does anyone have an idea of how to handle this?

Many thanks in advance for your help!!

3 Answers



0



accepted

The reason for the error 'Error message: G0505: Invalid structure redefinition 'glmOut'' is that you have d_hat_structure declared in your list of local variables and declared with the line:

struct glmOut d_hat_structure;

Structures declared as shown in the line above are created as local variables. Structures should not be put in the local variable list. The local variable list is for weakly typed variables such as matrices, strings, arrays, etc.

What you need to do is:

  1. Remove d_hat_structure from the local variable list.
  2. Remove the new and cls from inside the procedure.

new should never be inside a procedure. If it is in a program, it should always be the first line. It will clear all your data and procedures, so it cannot be used in a procedure.

aptech

1,548


0



Thanks, that worked well!

However, if I know want to extract some values from the structure, this is not possible any longer:

proc(1) = est2(x_1, y_1, d_1, z_1);
local vnam, m, b, stb, vc, stderr, sigma, cx, rsq, resid, dwstat, cov_2_1, cov_2_2, beta_est2_2, y_hat_logit_2_2, d_hat_logit_2_1, res_est2;

// prepare datasets as under OLS
cov_2_1 = z_1 ~ x_1[.,4:6];

// create glm structure
struct glmControl d_hat_structure;
d_hat_structure = glm(d_1,cov_2_1,"binomial");

d_hat_logit_2_1 = d_hat_structure.yhat;

gives me Error 'G0504: Invalid structure member 'yhat' for the last line of the code. However, .yhat should be a member of the structure.

 

Many thanks again!



0



The problem this time is that you have made d_hat_structure a glmControl structure instead of a glmOut structure. The glmControl structure contains the optional settings for the glm estimation. The one you want is the glmOut structure which holds the estimation results.

aptech

1,548

Your Answer


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

Try GAUSS for 30 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy