13 July 2018

What is this app?

This app aims at fitting a Linear Regression Model on Chatterjee-Price Attitude Data

What to Expect-

From a survey of the clerical employees of a large financial organization, the data are aggregated from the questionnaires of the approximately 35 employees for each of 30 (randomly selected) departments. The numbers give the percent proportion of favourable responses to seven questions in each department")

  • Linear model plotted of outcome against main predictor,interact to plot regression line
  • Extra predictor can be selected from the sidebar which changes the regression line's slope and intercept

Procedure Used

shinyServer(function(input, output) {
  model <- reactive({
    brushed_data <- brushedPoints(attitude, input$BRUSH,
                                  xvar = "rating", yvar = "raises")
    if(nrow(brushed_data) < 2){
      return(NULL)
    }
    else{
    if(input$V%in%"")
    {
    lm(raises~rating,data=brushed_data)
    }
     else{
       pred<-input$V
      Pred<-brushed_data[,pred]
    lm(raises~rating+Pred,data=brushed_data)
    }}
      })})

Output Code-Slope,Intercept & Plot

output$slope <- renderText({
    if(is.null(model())){
      "No Model Found"
    } else {
      model()[[1]][2]
    }})
  output$int <- renderText({
    if(is.null(model())){
      "No Model Found"
    } else {
      model()[[1]][1]
    }})
    output$FitPlot<-renderPlot({
      plot(attitude$rating,attitude$raises,
           ylab = "Raises",xlab="Rating", main = "Raises vs Rating",
           col="blue",pch=19,bty="n")
      if(!is.null(model())){
        abline(model(), col = "red",lwd=2.2)
      }})

Linear Model Fit Example