MLE with weight (cont)

For some reason, I cannot log in and continue answering the post I wrote yesterday.

 

For the question on how to use weights in MLE when each observation has an assigned weight, the following is a part of the code I am using.

_max_CovPar=    1;  /* Computation method for variance-covariance matrix */

_max_Algorithm=  4;  /* Maximization method */

{ x, f0, g, h, retcode } = MAXLIK( newy, 0, &lpsn, x0 );

call MAXPrt(x,f0,g,h,retcode);      @ x - parameter estiamtes @

I cannot figure out how to apply these individual weights. Any help/comments or example would be greatly appreciated.

1 Answer



0



maxlik has a global control variable __weight which you can use to set observations weights. It assumes that the sum of the weights is the sum of the number of observations.

// Weight each observation equally
__weight = ones(rows(newy), 1);

_max_CovPar=    1;  /* Computation method for variance-covariance matrix */

_max_Algorithm=  4;  /* Maximization method */

{ x, f0, g, h, retcode } = MAXLIK( newy, 0, &lpsn, x0 );

call MAXPrt(x,f0,g,h,retcode);      @ x - parameter estiamtes @

Here is a quick example showing how to adjust the weights so that the first 10 observations have half the weight of the second 10.

// Create a 20x1 vector containing the ratios you want for weights
// here obervations 11-20 will be weighted at 2 times
// observations 1-10
__weight = reshape(1, 10, 1) | reshape(2, 10, 1)

// Adjust the weights so they keep the same
// ratio and sum to the rows(__weight)
__weight = .* (rows(__weight) ./ sumc(__weight));

aptech

1,773

Your Answer

1 Answer

0

maxlik has a global control variable __weight which you can use to set observations weights. It assumes that the sum of the weights is the sum of the number of observations.

// Weight each observation equally
__weight = ones(rows(newy), 1);

_max_CovPar=    1;  /* Computation method for variance-covariance matrix */

_max_Algorithm=  4;  /* Maximization method */

{ x, f0, g, h, retcode } = MAXLIK( newy, 0, &lpsn, x0 );

call MAXPrt(x,f0,g,h,retcode);      @ x - parameter estiamtes @

Here is a quick example showing how to adjust the weights so that the first 10 observations have half the weight of the second 10.

// Create a 20x1 vector containing the ratios you want for weights
// here obervations 11-20 will be weighted at 2 times
// observations 1-10
__weight = reshape(1, 10, 1) | reshape(2, 10, 1)

// Adjust the weights so they keep the same
// ratio and sum to the rows(__weight)
__weight = .* (rows(__weight) ./ sumc(__weight));


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.