regression - How to create interactive dummy in Shiny -
i'm trying create shiny application interactive regressions. idea select variables , according these created dummys perform regression.
but when try create dummy, variable has zeros , regression turns out naive model. ideas?
this image of application, regression model has intercept , doesnt chagen when change options
this code
require(shiny) puntaje_2016_1 <- read_dta("e:/evaluacion/bases/puntaje 2016-1.dta") datas <- data.frame(depto = c(puntaje_2016_1$estu_reside_depto), mun = c(puntaje_2016_1$estu_reside_mcpio) , cole = c(puntaje_2016_1$cole_nombre_sede) ) runapp(list( ui = fluidpage( sidebarpanel( selectinput("depto", "deptos", choices = levels(datas$depto), selected = levels(datas$depto)[1]), selectinput("mun", "municipios", choices = datas$file[datas$depto == levels(datas$depto)[1]], multiple = false), selectinput("coles", "coles", choices = datas$cole[datas$mun == levels(datas$mun)[1]], multiple = false) ), mainpanel( verbatimtextoutput(outputid = "regsum") ) ), server = function(input, output, session) { rv<-reactivevalues(m=data.frame(puntaje_2016_1)) observe({ depto <- input$depto updateselectinput(session, "mun", choices = datas$mun[datas$depto == depto]) here try create interactive dummys variables
rv$c<-reactivevalues(a=ifelse(puntaje_2016_1$estu_reside_depto == "depto",1,0)) }) observe({ mun <- input$mun updateselectinput(session, "coles", choices = datas$cole[datas$mun == mun]) }) here make regression between fixed dependet var , interactive independent variable
lm1 <- reactive({lm(rv$m$punt_matematicas ~ rv$c$a)}) output$regsum <- renderprint(summary(lm1())) } )) thanks
Comments
Post a Comment