Skip to contents

Transforms a vector with a normal distribution to a binomial distribution with two values.

Usage

norm2ordinal(x, k)

Arguments

x

Input vector

k

Number of discrete values (e.g., 2=binary, 5=likert scale)

Value

A ordinal or binary variable

Examples

norm2ordinal(x = rnorm(n = 100,mean = 0,sd = 1),k=2)
#>             [,1]
#>   [1,]  0.955953
#>   [2,] -1.035616
#>   [3,] -1.035616
#>   [4,] -1.035616
#>   [5,]  0.955953
#>   [6,]  0.955953
#>   [7,] -1.035616
#>   [8,]  0.955953
#>   [9,] -1.035616
#>  [10,] -1.035616
#>  [11,]  0.955953
#>  [12,] -1.035616
#>  [13,] -1.035616
#>  [14,]  0.955953
#>  [15,]  0.955953
#>  [16,] -1.035616
#>  [17,]  0.955953
#>  [18,] -1.035616
#>  [19,] -1.035616
#>  [20,]  0.955953
#>  [21,] -1.035616
#>  [22,] -1.035616
#>  [23,] -1.035616
#>  [24,]  0.955953
#>  [25,] -1.035616
#>  [26,]  0.955953
#>  [27,]  0.955953
#>  [28,]  0.955953
#>  [29,] -1.035616
#>  [30,]  0.955953
#>  [31,] -1.035616
#>  [32,] -1.035616
#>  [33,] -1.035616
#>  [34,]  0.955953
#>  [35,] -1.035616
#>  [36,]  0.955953
#>  [37,] -1.035616
#>  [38,] -1.035616
#>  [39,]  0.955953
#>  [40,] -1.035616
#>  [41,] -1.035616
#>  [42,] -1.035616
#>  [43,]  0.955953
#>  [44,]  0.955953
#>  [45,]  0.955953
#>  [46,] -1.035616
#>  [47,] -1.035616
#>  [48,] -1.035616
#>  [49,]  0.955953
#>  [50,] -1.035616
#>  [51,]  0.955953
#>  [52,]  0.955953
#>  [53,]  0.955953
#>  [54,]  0.955953
#>  [55,] -1.035616
#>  [56,]  0.955953
#>  [57,] -1.035616
#>  [58,] -1.035616
#>  [59,] -1.035616
#>  [60,] -1.035616
#>  [61,]  0.955953
#>  [62,]  0.955953
#>  [63,]  0.955953
#>  [64,] -1.035616
#>  [65,] -1.035616
#>  [66,]  0.955953
#>  [67,]  0.955953
#>  [68,] -1.035616
#>  [69,]  0.955953
#>  [70,]  0.955953
#>  [71,]  0.955953
#>  [72,]  0.955953
#>  [73,] -1.035616
#>  [74,] -1.035616
#>  [75,] -1.035616
#>  [76,]  0.955953
#>  [77,]  0.955953
#>  [78,] -1.035616
#>  [79,]  0.955953
#>  [80,] -1.035616
#>  [81,]  0.955953
#>  [82,]  0.955953
#>  [83,]  0.955953
#>  [84,] -1.035616
#>  [85,] -1.035616
#>  [86,] -1.035616
#>  [87,]  0.955953
#>  [88,]  0.955953
#>  [89,]  0.955953
#>  [90,] -1.035616
#>  [91,] -1.035616
#>  [92,] -1.035616
#>  [93,]  0.955953
#>  [94,]  0.955953
#>  [95,]  0.955953
#>  [96,]  0.955953
#>  [97,]  0.955953
#>  [98,]  0.955953
#>  [99,]  0.955953
#> [100,]  0.955953
#> attr(,"scaled:center")
#> [1] 0.52
#> attr(,"scaled:scale")
#> [1] 0.5021167