Get Linear Model (Predictive Formula) App

Luis Luévano
2015/06/21

What does the application do ?

This application is intended to bring simplicity to a user not familiar with a statistical tool in order to get a predictive formula. In this app we use a linear regression model without intercept.

The input data is:

  • Dependent variable data. This is the sample data from the variable that user wants to predict. Each numeric value must be separated by comma.
  • Number of predictive variables. User can select from 1 to 5 variables that predict the outcome (dependent variable)
  • Five fields to enter the values related to the predictive variables.

Input User Validations

The app does these basic validations:

  • Makes sure that input data is entered in the dependent variable.
  • Makes sure that input data is actually entered in each predictive variable based on the number specified. If data is entered in a variable greater than the number of variables selected, it or they will be ignored.
  • Makes sure that number of elements in each predictive variable matches against the depended variable.

Example

Suppose that user wants to predict the following outcome:

y <- c(3,4,2,3,6)
x1 <- c(-5,0,1,2,3)
x2 <- c(0,0,9,8,9)

User must enter in Dependent variable data the string “3,4,2,3,6”, select Number of predictive variables to 2, and finally put the strings “-5,0,1,2,3” and “0,0,9,8,9” in Variable 1 data and Variable 1 data respectively.

Example (Cont.)

The predictive formula would be calculated as:

fit <- lm(y ~ x1 + x2 -1)
paste0('DepVar = ', 'Var1*', round(fit$coeff[[1]], 2),' + ','Var2*', round(fit$coeff[[2]], 2))
[1] "DepVar = Var1*-0.41 + Var2*0.52"