@@ -463,7 +463,7 @@ function fit(
463463 end
464464
465465 # Get the indicator matrix
466- XI, rd, dr = make_indicators (X)
466+ XI, rd, dr = make_indicators (X, " active " )
467467
468468 # Create the underlying correspondence analysis value
469469 C = fit (CA, XI; d = d, normalize = normalize, method = method)
@@ -490,7 +490,7 @@ function quali_passive(mca::MCA, passive; normalize = "principal")
490490 error (" Wrong number of rows in passive data array" )
491491 end
492492
493- PI, _, drp = make_indicators (passive)
493+ PI, _, drp = make_indicators (passive, " passive " )
494494 r = quali_passive (C, PI; normalize = normalize)
495495
496496 vnames = if typeof (passive) <: AbstractDataFrame
@@ -508,19 +508,21 @@ end
508508# values in the vector 'z'. Also returns dictionaries mapping
509509# the unique values to column offsets, and mapping the column
510510# offsets to the unique values.
511- function make_single_indicator (z:: Vector{T} ) where {T}
511+ function make_single_indicator (z:: AbstractVector , vtype :: String , pos :: Int )
512512
513513 n = length (z)
514514
515515 # Unique values of the variable
516516 uq = sort (unique (z))
517517
518- if length (uq) > 50
519- @warn (" Nominal variable has more than 50 levels" )
518+ # This situation usually results from user error so warn.
519+ if length (uq) > 20
520+ @warn (" $(titlecase (vtype)) variable in column $(pos) has more than 20 levels" )
520521 end
521522
522523 # Recoding dictionary, maps each distinct value in z to
523524 # an offset
525+ T = eltype (z)
524526 rd = Dict {T,Int} ()
525527 rdi = []
526528 for (j, v) in enumerate (uq)
551553# In addition to the indicator matrix, return vectors of
552554# dictionaries mapping levels to positions and positions
553555# to levels for each variable.
554- function make_indicators (Z)
556+ function make_indicators (Z, vtype :: String )
555557
556558 if size (Z, 1 ) == 0
557559 return zeros (0 , 0 ), Dict[], Vector[]
@@ -560,7 +562,7 @@ function make_indicators(Z)
560562 rd, rdi = Dict[], Vector[]
561563 XX = []
562564 for j = 1 : size (Z, 2 )
563- X, dv, di = make_single_indicator (Z[:, j])
565+ X, dv, di = make_single_indicator (Z[:, j], vtype, j )
564566 push! (rd, dv)
565567 push! (rdi, di)
566568 push! (XX, X)
0 commit comments