rmm_reshape: Reshape Long-Format Data

View source: R/rmm_reshape_Rcpp.R

rmm_reshapeR Documentation

Reshape Long-Format Data

Description

This function reshapes a 'Long-Format' data (with the repeated measurements in separate rows) to 'Wide-Format' data (with repeated measurements in separate columns of the same row). The reshaped 'wide-format' data is an S3 class called 'rmm_data' and contains information for fitting the model with the rmm function. Users who want to use the rmm function must first use the rmm_reshape function. The rmm function receives only S3 class 'rmm_data' as input.

Usage

rmm_reshape(data, idvar, resp, alts, asv, min_obs)

Arguments

data

data frame, a 'Long-Format' transaction data.

idvar

character, variable name representing each individual's id in the transaction data.

resp

character, variable name representing result of a individual choice.

alts

character vector, variable names representing a alternatives.

asv

character vector, variable names representing a alternative specific variables.

min_obs

numeric, specify the minimum observation for each choice set in the transaction data.

Value

The 'Wide-Format' data and various information required for the rmm function.

See Also

rmm for estimating parameters.

Examples


data(Hotel_Long)

rst_reshape <- rmm_reshape(data=Hotel_Long, idvar="Booking_ID",
resp="Purchase", alts="Room_Type", asv="Price", min_obs=30)

class(rst_reshape)  # "rmm_data"
ls(rst_reshape)     # "Alts_Code_Desc" "ASV" "asv_name" "data_wide"
                    # "Rem_Choice_Set"     "Removed_Choice_Set"

rst_reshape$data_wide  # reshaped data


RMM documentation built on May 9, 2022, 5:08 p.m.

Related to rmm_reshape in RMM...