Rainer M Krug
2014-Oct-03 12:51 UTC
[R] comparing two "half-normal production" stochastic frontier functions
Hi I am using the function frontier::sfa (from the package frontier) to estimate several "half-normal production" stochastic frontier functions. Now I want to compare the coefficients of the linear frontier function and see if they are different. According to my stackexchange (CrossValidated) question [1] I can compare these as I can compare a normal linear regression. In R, I would uswe the function anova to do this model comparison - correct? Now this function does not accept objects of the type 'frontier' - so how can I do this comparison in R? To re-iterate, I want to know if the coefficients of the frontier line (slope and intercept) are significantly different. Below please find a reproducible example based on data provided in the package, of what I did, and below the transcript. Thanks, Rainer --8<---------------cut here---------------start------------->8--- library(frontier) data(front41Data) dat1 <- front41Data[1:30,] dat2 <- front41Data[30:60,] x1 <- sfa(log(output) ~ log(capital), data=dat1) x2 <- sfa(log(output) ~ log(capital), data=dat2) x1 x2 anova(x1, x2 --8<---------------cut here---------------end--------------->8--- ,---- | > library(frontier) | > data(front41Data) | > dat1 <- front41Data[1:30,] | > dat2 <- front41Data[30:60,] | > x1 <- sfa(log(output) ~ log(capital), data=dat1) | > x2 <- sfa(log(output) ~ log(capital), data=dat2) | Warning message: | In sfa(log(output) ~ log(capital), data = dat2) : the parameter | 'gamma' is close to the boundary of the parameter space [0,1]: this | can cause convergence problems and can negatively affect the validity | and reliability of statistical tests and might be caused by model | misspecification | > x1 | | Call: | sfa(formula = log(output) ~ log(capital), data = dat1) | | Maximum likelihood estimates | (Intercept) log(capital) sigmaSq gamma | 2.8646 0.2642 0.4364 0.8243 | > x2 | | Call: | sfa(formula = log(output) ~ log(capital), data = dat2) | | Maximum likelihood estimates | (Intercept) log(capital) sigmaSq gamma | 2.7035 0.4550 0.9736 0.9972 | > | > anova(x1, x2) | Error in UseMethod("anova") : | no applicable method for 'anova' applied to an object of class "frontier" `---- Footnotes: [1] http://stats.stackexchange.com/questions/117319/comparing-coefficients-of-linear-stochastic-frontier-production-and-cost-funct -- Rainer M. Krug email: Rainer<at>krugs<dot>de PGP: 0x0F52F982 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 494 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20141003/f9e25f8c/attachment.bin>
Arne Henningsen
2014-Oct-04 04:59 UTC
[R] comparing two "half-normal production" stochastic frontier functions
Dear Rainer On 3 October 2014 14:51, Rainer M Krug <Rainer at krugs.de> wrote:> I am using the function frontier::sfa (from the package frontier) to > estimate several "half-normal production" stochastic frontier functions. > > Now I want to compare the coefficients of the linear frontier function > and see if they are different. > > According to my stackexchange (CrossValidated) question [1] I can > compare these as I can compare a normal linear regression. > > In R, I would uswe the function anova to do this model comparison - > correct? > > Now this function does not accept objects of the type 'frontier' - so > how can I do this comparison in R? > > To re-iterate, I want to know if the coefficients of the frontier line > (slope and intercept) are significantly different. > > Below please find a reproducible example based on data provided in the > package, of what I did, and below the transcript. > > --8<---------------cut here---------------start------------->8--- > library(frontier) > data(front41Data) > dat1 <- front41Data[1:30,] > dat2 <- front41Data[30:60,] > x1 <- sfa(log(output) ~ log(capital), data=dat1) > x2 <- sfa(log(output) ~ log(capital), data=dat2) > x1 > x2 > anova(x1, x2 > --8<---------------cut here---------------end--------------->8---library( "frontier" ) data( "front41Data" ) # estimate pooled model mp <- sfa( log(output) ~ log(capital), data = front41Data ) # create a dummy variable front41Data$dum <- rep( c( 1, 0 ), 30 ) # estimate model with different intercepts and different slopes # but the same sigmsSq and the same gamma md <- sfa( log(output) ~ log(capital)*dum, data = front41Data ) # likelihood ratio test lrtest( mp, md ) If you have further questions regarding the frontier package, you may also use the "help" forum at frontier's R-Forge site: https://r-forge.r-project.org/projects/frontier/ ...and please do not forget to cite the frontier package in your publications (see output of the R command 'citation("frontier")'). Best regards, Arne -- Arne Henningsen http://www.arne-henningsen.name