Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 'Too few quotes' error for Cronbach's alpha command

    Hi,

    Hoping someone can help me. I'm trying to perform the Cronbach's alpha test on 8 variables for a scale construction. I've tidied all variables to remove missing values, but when trying the alpha command I'm getting the error message 'too few quotes'. I've used exactly the same code with different variable earlier in my analysis and it's worked, but I'm pretty much a beginner so I could be doing something wrong. Here's the code I'm using:

    alpha GovTrust_nm MPsTrust_nm LoseTch_nm VoteIntr_nm PtyNMat2_nm GovNoSay_nm VoteOnly_nm GovComp_nm, item label min(5)

    I've also tried with parentheses around the variable names but got the same message. Can anyone help?

  • #2
    I have not used alpha that I can recall but my guess is different. I suspect a subtle bug because there is something slightly awkward with your variable or value labels.

    You should please

    Code:
    set trace on
    and re-run the command and copy and paste a big enough chunk of the output including and before the fail so that we can see where the command is failing.

    Opening a log file first may make this easier for you.

    Comment


    • #3
      Try omitting the label option. Perhaps one of your variable labels has a sequence of characters not expected by alpha. If so, that is clearly an error in alpha but one you can work around by changing the offending label.

      The output of
      Code:
      describe GovTrust_nm MPsTrust_nm LoseTch_nm VoteIntr_nm PtyNMat2_nm GovNoSay_nm VoteOnly_nm GovComp_nm
      will display the variable labels for your variables.

      Comment


      • #4
        Thanks so much, I should have mentioned I'm using Stata 13 and there definitely are some bugs. I'm unfamiliar with the output from the set trace on command but looking at it I think I can see what's causing the problem - where it's truncated the labels I've given to the variable, there's some quote marks missing at the end of the final variable - any idea how I rectify this? Shall I try just giving it a different, shorter label and see if that works?


        ----------------------------------------------------------------------------------------------------- begin alpha.MaxVarLab ---
        - args varlist
        - tempname llen vlen
        - scalar `llen' = 0
        = scalar __00000R = 0
        - scalar `vlen' = 0
        = scalar __00000S = 0
        - foreach v of local varlist {
        - scalar `vlen' = max(`vlen', length("`v'"))
        = scalar __00000S = max(__00000S, length("GovTrust_nm"))
        - local vl : var label `v'
        = local vl : var label GovTrust_nm
        - scalar `llen' = max(`llen', length(`"`vl'"'))
        = scalar __00000R = max(__00000R, length(`"How much do you trust British governments of any party to place the needs of the"'))
        - }
        - scalar `vlen' = max(`vlen', length("`v'"))
        = scalar __00000S = max(__00000S, length("MPsTrust_nm"))
        - local vl : var label `v'
        = local vl : var label MPsTrust_nm
        - scalar `llen' = max(`llen', length(`"`vl'"'))
        = scalar __00000R = max(__00000R, length(`"And how much do you trust politicians of any party in Britain to tell the truth "'))
        - }
        - scalar `vlen' = max(`vlen', length("`v'"))
        = scalar __00000S = max(__00000S, length("LoseTch_nm"))
        - local vl : var label `v'
        = local vl : var label LoseTch_nm
        - scalar `llen' = max(`llen', length(`"`vl'"'))
        = scalar __00000R = max(__00000R, length(`"How much do you agree or disagree that generally speaking those we elect as MPs "'))
        - }
        - scalar `vlen' = max(`vlen', length("`v'"))
        = scalar __00000S = max(__00000S, length("VoteIntr_nm"))
        - local vl : var label `v'
        = local vl : var label VoteIntr_nm
        - scalar `llen' = max(`llen', length(`"`vl'"'))
        = scalar __00000R = max(__00000R, length(`"How much do you agree or disagree that parties are only interested in people))
        too few quotes
        }
        ------------------------------------------------------------------------------------------------------- end alpha.MaxVarLab ---
        local lenlabel = max(r(llen),length(`"`testtxt'"'))
        local lenpiece = min(`lenlabel',`linesize'-69)
        local duplen = 55 + `lenpiece'
        di
        di as txt " item-test item-rest interitem"
        di as txt "Item {c |} Obs Sign corr. corr. `lab' alpha Label"
        di as txt "{hline 13}{c +}{hline `duplen'}"
        forvalues i = 1/`k' {
        di as txt abbrev("``i''", 12) "{col 14}{c |} " as res _col(16) %4.0f `Obs'[`i',`i'] _col(24) =cond("`sgn`i''" == "1", "+", "-")
        > _col(28) %7.4f `ITC'[1,`i'] _col(39) %7.4f `IRC'[1,`i'] _col(49) `fmt' `mIIC'[1,`i'] _col(61) %6.4f `alph'[1,`i'] _col(70) _c
        DiVarLab ``i'' `lenpiece' 72
        }
        di as txt "{hline 13}{c +}{hline `duplen'}"
        di as txt "Test scale{col 14}{c |}" as res _col(49) `fmt' `acorr' _col(61) %6.4f `alpha' _col(70) as txt `"`testtxt'"'
        di as txt "{hline 13}{c BT}{hline `duplen'}"
        }
        ------------------------------------------------------------------------------------------------------------------- end alpha ---
        r(132);

        end of do-file

        Comment


        • #5
          A much shorter variable label is likely to fix this and be a good idea for table and graph output any way.

          Comment


          • #6
            It is probably not about the length of the labels.

            Code:
            How much do you agree or disagree that parties are only interested in people
            produces the error message; but

            Code:
            How much do you agree or disagree that generally speaking those we elect as MPs
            appears to work fine despite the longer string.

            My guess is that there are unescaped single left quotes, i. .e, ` in the original labels. Here is an example

            Code:
            . sysuse auto
            (1978 Automobile Data)
            
            . label variable mpg "single left ` quote"
            
            . alpha price mpg turn , item label
            
            Test scale = mean(unstandardized items)
            too few quotes
            r(132);

            Edit:

            Forgot to mention the obvious workaround: change the single left quotes to sth. else, e. g., single right quotes. It is easy enough with extended functions but here are two ways of doing this with elabel (SSC).

            Code:
            elabel variable ( * ) ( = subinstr(@, "`", "'", .) )
            or

            Code:
            elabel variable ( * ) ( = subinstr(@, char(96), char(39), .) )
            Last edited by daniel klein; 07 Jan 2022, 14:55.

            Comment

            Working...
            X