[R] DEA -- Extract the Frontier and ggplot2

Roman Luštrik roman.lustrik at gmail.com
Tue Aug 2 12:13:47 CEST 2016


Hi,

this is not really a ggplot2 issue, but here goes.

If you look at the source code of the Benchmarking package (here
<https://github.com/cran/Benchmarking/blob/master/R/dea.plot.R>) you will
notice that the function is not very explicit about what to return - so the
returned thing is actually a plotting line (lines()). What you could do is
fork the repository, add your own return statement to include the `hpts`
<https://github.com/cran/Benchmarking/blob/master/R/dea.plot.R#L227> which
could be used to find the correct values in `x` (see for example here
<https://github.com/cran/Benchmarking/blob/master/R/dea.plot.R#L231> how
plotting is done).

After you have the formed repository ready (and pushed to your account),
you can install it through
devtools::install_github("yourname/Benchmarking"). Blesssed thee, open
source.

Cheers,
Roman

On Tue, Aug 2, 2016 at 11:11 AM, Lorenzo Isella <lorenzo.isella at gmail.com>
wrote:

> Hello,
> Thanks for your suggestion, but it is does not help me much.
> Indeed, in this case where RTS="vrs", things are easy as you say.
> However, try for instance to change the technology assumption
> (e.g. replace it with RTS="drs" everywhere in my script) and you'll
> see that things are not that simple.
> I really need a way to extract the frontier -- it is plotted, so it is
> calculated and it has to be buried somewhere in the package, just I do
> not know where.
> Cheers
>
> Lorenzo
>
> On Tue, Aug 02, 2016 at 09:05:15AM +0000, Jose Iparraguirre wrote:
>
>> Lorenzo,
>>
>> dea.plot plots the vectors x and y, which you already have:
>> data.frame(x,y)
>>   x  y
>> 1 20 20
>> 2 40 30
>> 3 40 50
>> 4 60 40
>> 5 70 60
>> 6 50 20
>>
>> dea.plot.frontier plots the highest values of y for each value of x.
>> Therefore, for x=20, the plot goes through y=20 but for X=40, where you
>> have Y=30 and Y=50, the plot goes through the latter.
>>
>> Others in the list may give you an easier and better answer, but it's not
>> difficult to plot all the X and Y in a scatterplot in ggplot and then to
>> add a line along the highest values of Y per each X.
>>
>> I'm assuming you want an input orientation as in your example, of course.
>>
>> Hope it helps,
>>
>> José
>>
>>
>> Prof. José Iparraguirre
>> Chief Economist
>> Age UK
>>
>> Age UK
>> Tavis House, 1- 6 Tavistock Square
>> London, WC1H 9NB
>>
>> T 020 303 31482
>> E Jose.Iparraguirre at ageuk.org.uk<mailto:Jose.Iparraguirre at ageuk.org.uk>
>> Twitter @jose.iparraguirre at ageuk
>>
>> www.ageuk.org.uk<http://www.ageuk.org.uk/> | ageukblog.org.uk |
>> @ageukcampaigns
>>
>>
>> Interested in our Policy and Research publications? Sign up to our
>> monthly bulletin at
>> http://www.ageuk.org.uk/professional-resources-home/research/
>>
>> For evidence and statistics on the older population, visit the Age UK
>> Knowledge Hub
>> http://www.ageuk.org.uk/professional-resources-home/knowledge-hub-evidence-statistics/
>>
>>
>>
>>
>> From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Lorenzo
>> Isella
>> Sent: 02 August 2016 09:05
>> To: r-help at r-project.org
>> Cc: ggplot2 at googlegroups.com
>> Subject: [R] DEA -- Extract the Frontier and ggplot2
>>
>> Dear All,
>> Please consider the code at the end of the email.
>> Everything is fine in this little example, just I do not know how to
>> extract the DEA frontier (solid line in the plot).
>> The reason is that I want to reproduce a more complicated DEA frontier
>> plot using ggplot2 and I need to understand how I can extract the
>> frontier data. Alternatively: can anyone reproduce the same plot with
>> ggplot2?
>> Many thanks
>>
>> Lorenzo
>>
>> ###########################################à
>>
>>
>>
>> library(Benchmarking) # load the Benchmarking library
>>
>> x <- matrix(c(20, 40, 40, 60, 70, 50),ncol=1) #define inputs
>> y <- matrix(c(20, 30, 50, 40, 60, 20),ncol=1) #define outputs
>>
>> e_vrs <- dea(x,y, RTS="vrs", ORIENTATION="in")#solve LP problem
>> eff_dea <- eff(e_vrs) #select efficiency scores from the results in e
>>
>>
>>
>>
>> dd <- as.data.frame(cbind(x,y))
>>
>> names(dd) <- c("Input", "Output")
>> dd$Firm <- LETTERS[1:length(x)]
>>
>> dd$Input <- as.integer(dd$Input)
>> dd$Output <- as.integer(dd$Output)
>>
>> pdf("dea-frontier-vrs.pdf")
>> par( mar = c(4.5,5, 1, 1) + 0.1)
>>
>> dea.plot(x,y,RTS="vrs",ORIENTATION="in",txt=LETTERS[1:length(x)],lty="dashed",
>> xlab="Input", ylab="Output", fex=2,
>> cex=2,cex.lab=2,cex.axis=2)
>> dea.plot.frontier(x,y, RTS="vrs", add=T)
>> text(10,60, "VRS", cex=2)
>> dev.off()
>>
>> ______________________________________________
>> R-help at r-project.org<mailto:R-help at r-project.org> mailing list -- To
>> UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help<
>> https://stat.ethz.ch/mailman/listinfo/r-help>
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html<
>> http://www.R-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>>
>>
>>
>> Age UK
>>
>> Together, we can help everyone make the most of later life.
>>
>> Get involved and find out how you can donate, volunteer or give your
>> support to help more people love later life at www.ageuk.org.uk
>>
>>
>> -------------------------------------------------------------------------------------------------------
>> Age UK is a registered charity and company limited by guarantee,
>> (registered charity number 1128267, registered company number 6825798)
>> Registered office: Tavis House, 1-6 Tavistock Square, London WC1H 9NA
>> Charitable Services are offered through Age UK (the Charity) and
>> commercial products and services are offered by the Charity’s subsidiary
>> companies. The Age UK Group comprises of Age UK, and its subsidiary
>> companies and charities, dedicated to helping more people make the most of
>> later life. Our network includes the three national charities Age Cymru,
>> Age NI and Age Scotland and more than 150 local Age UK charities.
>>
>> -------------------------------------------------------------------------------------------------------
>> This email and any files transmitted with it are confidential and
>> intended solely for the use of the individual or entity to whom they are
>> addressed. If you receive a message in error, please advise the sender and
>> delete immediately.
>> Except where this email is sent in the usual course of our business, any
>> opinions expressed in this email are those of the author and do not
>> necessarily reflect the opinions of Age UK or its subsidiaries and
>> associated companies. Age UK monitors all e-mail transmissions passing
>> through its network and may block or modify mails which are deemed to be
>> unsuitable.
>>
>
>
> --
> --
> You received this message because you are subscribed to the ggplot2
> mailing list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email ggplot2 at googlegroups.com
> To unsubscribe: email ggplot2+unsubscribe at googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>
> --- You received this message because you are subscribed to the Google
> Groups "ggplot2" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ggplot2+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
In God we trust, all others bring data.

	[[alternative HTML version deleted]]



More information about the R-help mailing list