Brief Presentation of my shiny application - Fidelity Predictor

vpantea
2014-10-27

Used Data

This simple algorithm, is using a dataset from 601 participants from a cross-sectional survey conducted by Psychology Today in 1969. The input features, predictors of this survey contain such data as:

  • how often the respondent engaged in extramarital sexual intercourse during the past year
  • gender
  • sex
  • age
  • years of marriage
  • numeric self-rating of their marriage (from 1=very unhappy to 5=very happy)
  • religiousness (on a 5-point scale from 1=anti to 5=very)

R code used for fidelity prediction

library(shiny); library(AER)
data(Affairs, package="AER")
Affairs$ynaffair[Affairs$affairs > 0] <- 1
Affairs$ynaffair[Affairs$affairs == 0] <- 0
Affairs$ynaffair <- factor(Affairs$ynaffair, levels=c(0,1), labels=c("No","Yes"))
model_glm.reduced <- glm(ynaffair ~ age + yearsmarried + religiousness + rating, data=Affairs, family=binomial())

Prediction model

summary(model_glm.reduced)

Call:
glm(formula = ynaffair ~ age + yearsmarried + religiousness + 
    rating, family = binomial(), data = Affairs)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.6278  -0.7550  -0.5701  -0.2624   2.3998  

Coefficients:
              Estimate Std. Error z value Pr(>|z|)    
(Intercept)    1.93083    0.61032   3.164 0.001558 ** 
age           -0.03527    0.01736  -2.032 0.042127 *  
yearsmarried   0.10062    0.02921   3.445 0.000571 ***
religiousness -0.32902    0.08945  -3.678 0.000235 ***
rating        -0.46136    0.08884  -5.193 2.06e-07 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 675.38  on 600  degrees of freedom
Residual deviance: 615.36  on 596  degrees of freedom
AIC: 625.36

Number of Fisher Scoring iterations: 4

The UI

This shiny application has only 1 html page with left panel used by user to input the 4 predictors / variables that will feed my simple fidelity predictor based on the generalized linear model inp0lemented by glm function. In the right panel user inputs are repeated and the prediction result is displayed bottom right.