var2prof: Variables to Profiles

Description Usage Arguments Details Value See Also Examples

View source: R/var2prof.R

Description

The function allows the user to specify an arbitrary number of ordinal variables and produces the list of all the profiles built on them. See details to define the variables.

Usage

1
2
3
var2prof(varmod = lapply(as.list(varlen), function(x) 1:x),
    varlen = str(sapply(varmod, length)), freq = NULL,
    labtype = c("profiles", "progressive"), y=NULL)

Arguments

varmod

list of the variables and their modalities. See details.

varlen

a vector of the number of modalities of each variable. See details.

freq

profiles frequency distribution. By default, the frequencies are equal to 1, but through this parameter they can be sampled.

labtype

the user can choose the type of labels to assign to the profiles. See details.

y

an observations matrix, used to count the profiles frequencies. See details.

Details

Variables can be indicated by their names and modalities, through a list as argument varmod. The names of the objects of the list are the names of the variables. The objects of the list have to be ordered vectors or numeric vectors. Their elements represent the names of the modalities and they have to be comparable in order to build the incidence matrix (see getzeta).

A faster way to define the variables is through a vector of the number of modalities of each variable, as the argument varlen. By this way, to variables and to their modalities are assigned arbitrary names. In particular the modalities are identified by their ranks.

The user can choose the type label to assign to profiles. profiles is the combination of modailties that identify the profiles. When the names of the modalities are long, it is better to choose progressive, that assign to each profile a progressive number preceded by the letter "P".

The parameter y is a matrix of observation of the ordinal variables (observations by rows and variables by columns). The variables has to be ordered as they are defined in the preavious parameters. The names of the modalities of the variables have to match their definition. By this parameter the function counts the number of times that a profile is observed and assign the result to the freq output parameter. This method shuld be used when the variables and their modalities are known, otherwise the function pop2prof has to be used.

Value

The function returns an object of S3 class wprof, "weighted profiles", which contains the data.frame named profiles and the vector of frequencies freq.

See Also

pop2prof, getzeta

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# 2 variables with 2 modalities, frequencies detected from a population
pop <- matrix(sample(1:2, 200, replace=TRUE), 50, 2)
var2prof(varlen=c(2, 2))

# 2 variables:
# - mood: 2 modalities
# - weather: 3 modalities
# 2*3*2 profiles and frequencies sampled from a Binomial distribution n = 10, p = 0.5
var <- list(
    mood = as.ordered(c("bad", "good")),
    weather = as.ordered(c("rainy", "cloudy", "sunny"))
)
var2prof(var, freq = rbinom(2*3, 10, 0.5), labtype = "progressive")

parsec documentation built on May 2, 2019, 6:08 p.m.