@@ -463,7 +463,7 @@ function fit(
463
463
end
464
464
465
465
# Get the indicator matrix
466
- XI, rd, dr = make_indicators (X)
466
+ XI, rd, dr = make_indicators (X, " active " )
467
467
468
468
# Create the underlying correspondence analysis value
469
469
C = fit (CA, XI; d = d, normalize = normalize, method = method)
@@ -490,7 +490,7 @@ function quali_passive(mca::MCA, passive; normalize = "principal")
490
490
error (" Wrong number of rows in passive data array" )
491
491
end
492
492
493
- PI, _, drp = make_indicators (passive)
493
+ PI, _, drp = make_indicators (passive, " passive " )
494
494
r = quali_passive (C, PI; normalize = normalize)
495
495
496
496
vnames = if typeof (passive) <: AbstractDataFrame
@@ -508,19 +508,21 @@ end
508
508
# values in the vector 'z'. Also returns dictionaries mapping
509
509
# the unique values to column offsets, and mapping the column
510
510
# 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 )
512
512
513
513
n = length (z)
514
514
515
515
# Unique values of the variable
516
516
uq = sort (unique (z))
517
517
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" )
520
521
end
521
522
522
523
# Recoding dictionary, maps each distinct value in z to
523
524
# an offset
525
+ T = eltype (z)
524
526
rd = Dict {T,Int} ()
525
527
rdi = []
526
528
for (j, v) in enumerate (uq)
551
553
# In addition to the indicator matrix, return vectors of
552
554
# dictionaries mapping levels to positions and positions
553
555
# to levels for each variable.
554
- function make_indicators (Z)
556
+ function make_indicators (Z, vtype :: String )
555
557
556
558
if size (Z, 1 ) == 0
557
559
return zeros (0 , 0 ), Dict[], Vector[]
@@ -560,7 +562,7 @@ function make_indicators(Z)
560
562
rd, rdi = Dict[], Vector[]
561
563
XX = []
562
564
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 )
564
566
push! (rd, dv)
565
567
push! (rdi, di)
566
568
push! (XX, X)
0 commit comments