Hi to everyone.

I wish to discuss the following points:
1.) NEED HELP to compile
2.) ANOVA

2.) ANOVA
=========

I will start with point 2. Should I open a new thread for this, by the way?

I have appended a draft implementation of the *ANOVA function*, please see the code. There are still some unfinished issues, BUT I need help for those.

- the ANOVA code proper is finished
- depending on how to implement the variable arrays, it might become pertinent to keep track of array length
  -- IF implementing as vectors, NO such need
- some issues at initializing the function: like retrieving how many parameters and the like;
- I will discuss in a later post my ideas on how to implement the output

ANOVA is probably one of the last functions that could be implemented directly in Calc (Fisher exact test would be another one). All other advanced statistical functions should be best implemented through external software (e.g. R).

1.) COMPILING
============

Niklas Nebel wrote:
OOo can now be built on Windows using only free tools. Noel just posted something at http://noelpower.blogs.ie/2006/11/10/hurray-now-you-can-build-with-free-compiler-on-windows/. I haven't tried it myself, though.

I have NO idea how this goes. I need help. As I previously mentioned, I am NOT an IT professional. It just happens that I know some C++.

If anybody can compile this, I would be very thankful. It really corrects a bug inside Calc.


Kind regards,

Leonard Mada
void ScInterpreter::ScANOVA()
{
        // WE GET EITHER A SINGLE MATRIX WHERE EVERY COLUMN IS A SEPARATE 
VARIABLE
        //   DISADVANTAGE: ONLY ONE COLUMN PER VARIABLE
        // OR MULTIPLE MATRICES, EACH MATRIX IS ONE VARIABLE
        //   DISADVANTAGE:
        //      CALC FUNCTIONS ACCEPT ONLY 30 PARAMS
        //      SO THERE ARE AT MOST 30 VARIABLES

        SCSIZE iVarNr   = /* NUMBER OF PARAMETERS */; // NUMBER OF VARIABLES
        if ( iVarNr == 0 /* NO PARAMETERS */)
                return; // EXIT
        if ( iVarNr == 1 /* ONLY ONE PARAMETER */ )
                ScMatrixRef pMat = GetMatrix();
                if (!pMat) {
                        // NO DATA MATRIX - INVALID PARAMETERS
                        SetIllegalParameter();
                        return; }
                SCSIZE nC, nR;
                // WE HAVE ONLY ONE MATRIX
                // WE CONSIDER EVERY COLUMN AS A SEPARATE DATA SET
                pMat->GetDimensions(nC, nR);
                iVarNr = nC;
                nC = 1; // NOT REALLY NEEDED
                ScMatrixRef pMat[iVarNr];
                for(size_t i=0; i<iVarNr; i++) {
                        ScMatrixRef pMat[i] = /* COLUMN i FROM THE ORIGINAL 
MATRIX pMat */
                }
        else {
                ScMatrixRef pMat[iVarNr];
                for(size_t i=0; i<iVarNr; i++) {
                        ScMatrixRef pMat[i] = GetMatrix();
                        if (!pMat[i]) {
                                // NO DATA MATRIX - INVALID PARAMETERS
                                SetIllegalParameter();
                                return; }
                }
        }

        if( iVarNr == 1 ) {
                SetNoValue();
                return; // ONLY ONE VARIABLE - ANOVA NOT POSSIBLE
        }

        SCSIZE nC, nR; // DIMENSIONS OF ACTIVE MATRIX

        SCSIZE dfB   = 0; // DEGREES OF FREEDOM
        SCSIZE dfE   = 0; // DEGREES OF FREEDOM
        SCSIZE N     = 0; // TOTAL NUMBER OF DATA VALUES

        double fMSB = 0.0; // THIS IS INTER-GROUP VARIANCE
        double fMSE = 0.0; // THIS IS INTRA-GROUP VARIANCE (DUE TO ERROR)

        SCSIZE iCount   = 0; // NUMBER OF THE CURRENT VARIABLE
        SCSIZE jCount   = 0; // NUMBER OF VALUES FOR EACH VARIABLE

        double fSumM    = 0.0; // THIS IS THE GRAND MEAN
        double fSumX[iVarNr] ; // THIS STORES THE MEANS FOR THE INDIVIDUAL 
VARIABLES
        double fValX[iVarNr] [ /* WE DO NOT KNOW THIS */ ]; // THE VALUES

        for (; iCount < iVarNr; iCount++) {
                pMat[iCount]->GetDimensions(nC, nR);
                fSumX[iCount] = 0.0; // INITIALIZE THE SUM
                for (SCSIZE i = 0; i < nC; i++)
                        for (SCSIZE j = 0; j < nR; j++)
                        {
                                if (!pMat[iCount]->IsString(i,j))
                                {
                                        fValX[iCount][jCount] = 
pMat[iCount]->GetDouble(i,j);
                                        fSumX[iCount]    += 
fValX[iCount][jCount];
                                        jCount++;
                                }
                        }
                fSumM += fSumX[iCount];
                fSumX[iCount] = fSumX[iCount] / jCount; // THIS IS THE MEAN
                N += jCount;
                jCount = 0; // RESET jCount FOR NEXT VARIABLE
        } // END OUTER FOR LOOP

        if (iCount < 2)
                SetNoValue();
        else {
                dfB = iCount -1;
                dfE = N - iCount;
                fSumM = fSumM / N; // THIS IS THE GRAND MEAN

                for(SCSIZE i = 0; i < iCount; i++) {
                        for(SCSIZE j = 0; j < /* INDIVIDUAL GROUP SIZE */; j++) 
{
                                // GROUPS MAY HAVE DIFFERENT SIZES
                                fMSE += (fValX[iCount][jCount] - fSumX[iCount]) 
* (fValX[iCount][jCount] - fSumX[iCount]);
                                // fMSB += (fSumM - fSumX[iCount]) * (fSumM - 
fSumX[iCount]);
                                // TO AVOID MORE COMPUTATIONS WE CAN CALCULATE 
fMSB OUTSIDE THIS LOOP
                        }
                        fMSB += /* INDIVIDUAL GROUP SIZE */ * (fSumM - 
fSumX[iCount]) * (fSumM - fSumX[iCount]);
                }
                fMSB = fMSB / dfB;
                fMSE = fMSE / dfE;
                PushDouble( fMSB/fMSE );
                // WE STILL NEED TO INTERPRET fMSB/fMSE USING THE F STATISTICS
        }
}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to