-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get_dummy() handling of vectors containing zeros #3
Comments
The same reasoning applies for Also, I wonder whether having 0s in categories like I did actually makes sense when computing the ordinal scale, so perhaps a conditional test should be introduced to prevent that users define ordinal variables like that? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I've spotted an issue with
get_dummy()
, when runningplspm()
with a model comprising ordinal variables with "0" as one of the categories.Let's assume we have a variable in a block
q
such thatXblocks[[q]][,p]
is made of numbers between 0 and 4 (i.e. 5 categories).Basically,
get_weights_nonmetric()
will fail at handling such variable, stopping at that line:get_ord_scale(Z[,q], Xblocks[[q]][,p], aux_dummy)
The reason is that in that case,
aux_dummy
lacks 1 column, precisely the column corresponding to the category "0".So I looked at how dummies are obtained, and found out that
get_dummy()
is at the root of the problem.As you can see, the number of columns
p
is based on the maximum value of x. But this won't work when 0s are present in x (p
would need to bemax(x)+1
).Very simply, defining
p
asp = length(unique(x))
ensures that the function works every time.Best,
G
The text was updated successfully, but these errors were encountered: