#' Create ordinal logistic regression
#' to measure likeliness to download mobile app
#' @param df
#'
#' @return
#' @export
#'
#' @examples
#' homework::model_ordinal(experiment_data)
model_ordinal <- function(df)
{
model_data <- df %>% dplyr::select(duration:answer) %>% dplyr::mutate(answer = as.factor(answer) )
model <- MASS::polr(answer ~ . , data = model_data, Hess=TRUE)
coef_table <- coef(summary(model))
p <- pnorm(abs(coef_table[, "t value"]), lower.tail = FALSE) * 2
coef_table<- cbind(coef_table, "p_value" = p)
coef_table <- tibble::as_tibble(coef_table, rownames = "Coef_name") %>%
dplyr::arrange(desc(Coef_name)) %>%
dplyr::slice(1:18) %>%
dplyr::mutate(Odds_ratio = exp(Value)) %>%
dplyr::arrange(p_value) %>%
dplyr::rename(Coef_value = Value) %>%
dplyr::select(Coef_name, Coef_value , p_value , Odds_ratio , everything())
return(coef_table)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.