Search code examples
rlogistic-regressiontrend

Building a logistic trend surface in R


I would like to build a very simple rectangular surface in R that would have a logistic trend. The values at the top would have the highest values (1) and at the bottom the lowest (0). I have drafted an image that shows example of the surface that I have in mind, with help of not the prettiest trend lines so you have an idea what is needed. I do not have any data, it is supposed to be a theoretical surface with logistic trend, that I am later going to modify. Any help with how to start/approach it, or helpful packages in R would be highly appreciated!

enter image description here


Solution

  • Consider this as a hint.

    library("graphics")
    
    plot(0:1, type = "n",xaxt="n", ann=FALSE)
    abline(h = c(seq(0,1,.1))
    

    or

    abline(h = c(0,.1,.2,.3,.6,.7,.8,.9))
    abline(h = c(0.4,.5), col="red")
    

    The only thing you have to do is place the variable, as you call it, with the “logistic trend,” in place of ‘0:1

    A second hint

    df = as.matrix(c(0.131313131,0.111111111,0.090909091,
                     0.080808081,0.060606061,0.050505051,
                     0.060606061,0.080808081,0.090909091,
                     0.111111111,0.131313131))
    
    barplot(prop.table(df, 2) )
    

    this results in

    enter image description here