Hi all, I have a problem to estimate Std. Error and t-value by ?polr? in library Mass. They result from the summary of a polr object. I can obtain them working in the R environment with the following statements: temp <- polr(formula = formula1, data = data1) coeff <- summary(temp), but when the above statements are enclosed in a function, summary reports the following error: Error in eval(expr, envir, enclos) : object "dat" not found Someone knows how I can solve the problem? Thanks for any help. Paolo
At 15:21 19/02/2007, Paolo Accadia wrote:>Hi all, > >I have a problem to estimate Std. Error and >t-value by ???polr??? in library Mass. >They result from the summary of a polr object. > >I can obtain them working in the R environment with the following statements: > > temp <- polr(formula = formula1, data = data1) > coeff <- summary(temp), > >but when the above statements are enclosed in a >function, summary reports the following error: > >Error in eval(expr, envir, enclos) : object "dat" not found > >Someone knows how I can solve the problem?By giving us a short reproducible example? Specifically we do not know: 1 - what formula1 is 2 - what the structure of data1 is 3 - what the enclosing function looks like 4 - what dat is>Thanks for any help. >PaoloMichael Dewey http://www.aghmed.fsnet.co.uk
At 14:41 20/02/2007, you wrote: Please do not just reply to me, 1 - I might not know 2 - it breaks the threading>Hi > >here there is an example extracted from polr help in MASS: > >The function could be: > > temp <- function(form, dat) { > house.plr <- polr(formula = > form, weights = Freq, data = dat) > coeff <- summary(house.plr) > return(coeff)}Why do you try to redefine the coeff extractor function? Try calling the results of summary summ or some other obvious name and I think you will find the problem goes away. See also > library(fortunes) > fortune("dog") Firstly, don't call your matrix 'matrix'. Would you call your dog 'dog'? Anyway, it might clash with the function 'matrix'. -- Barry Rowlingson R-help (October 2004)>the function can be called by: > > temp(Sat ~ Infl + Type + Cont, housing) > >where all data is available from MASS, as it is >an example in R Help on 'polr'. > >Results are: > > Re-fitting to get Hessian > > Error in eval(expr, envir, enclos) : object "dat" not found > >Paolo Accadia > > > >>> Michael Dewey <info at aghmed.fsnet.co.uk> 20/02/07 1:43 PM >>> >At 15:21 19/02/2007, Paolo Accadia wrote: > >Hi all, > > > >I have a problem to estimate Std. Error and > >t-value by ????polr??? in library Mass. >s. > >They result from the summary of a polr object. > > > >I can obtain them working in the R environment > with the following statements: > > > > temp <- polr(formula = formula1, data = data1) > > coeff <- summary(temp), > > > >but when the above statements are enclosed in a > >function, summary reports the following error: > > > >Error in eval(expr, envir, enclos) : object "dat" not found > > > >Someone knows how I can solve the problem? > >By giving us a short reproducible example? > >Specifically we do not know: >1 - what formula1 is >2 - what the structure of data1 is >3 - what the enclosing function looks like >4 - what dat is > > > >Thanks for any help. > >Paolo > >Michael Dewey >http://www.aghmed.fsnet.co.ukMichael Dewey http://www.aghmed.fsnet.co.uk
Thank you very much Paolo>>> Prof Brian Ripley <ripley at stats.ox.ac.uk> 20/02/07 4:00 PM >>>That's not it (the function is 'coef' not 'coeff', and R can tell functions and lists apart). If you read the help page for polr you will see you could have used Hess=TRUE. It works then. THAT is why we needed an example, to see how you used the function. On Tue, 20 Feb 2007, Michael Dewey wrote:> At 14:41 20/02/2007, you wrote: > Please do not just reply to me, > 1 - I might not know > 2 - it breaks the threading > >> Hi >> >> here there is an example extracted from polr help in MASS: >> >> The function could be: >> >> temp <- function(form, dat) { >> house.plr <- polr(formula >> form, weights = Freq, data = dat) >> coeff <- summary(house.plr) >> return(coeff)} > > Why do you try to redefine the coeff extractor function? > Try calling the results of summary summ or some > other obvious name and I think you will find the problem goes away. > > See also > > library(fortunes) > > fortune("dog") > > Firstly, don't call your matrix 'matrix'. Would you call your dog 'dog'? > Anyway, it might clash with the function 'matrix'. > -- Barry Rowlingson > R-help (October 2004) > > > >> the function can be called by: >> >> temp(Sat ~ Infl + Type + Cont, housing) >> >> where all data is available from MASS, as it is >> an example in R Help on 'polr'. >> >> Results are: >> >> Re-fitting to get Hessian >> >> Error in eval(expr, envir, enclos) : object "dat" not found >> >> Paolo Accadia >> >> >>>>> Michael Dewey <info at aghmed.fsnet.co.uk> 20/02/07 1:43 PM >>> >> At 15:21 19/02/2007, Paolo Accadia wrote: >>> Hi all, >>> >>> I have a problem to estimate Std. Error and >>> t-value by ????polr??? in library Mass. >> s. >>> They result from the summary of a polr object. >>> >>> I can obtain them working in the R environment >> with the following statements: >>> >>> temp <- polr(formula = formula1, data = data1) >>> coeff <- summary(temp), >>> >>> but when the above statements are enclosed in a >>> function, summary reports the following error: >>> >>> Error in eval(expr, envir, enclos) : object "dat" not found >>> >>> Someone knows how I can solve the problem? >> >> By giving us a short reproducible example? >> >> Specifically we do not know: >> 1 - what formula1 is >> 2 - what the structure of data1 is >> 3 - what the enclosing function looks like >> 4 - what dat is >> >> >>> Thanks for any help. >>> Paolo >> >> Michael Dewey >> http://www.aghmed.fsnet.co.uk > > Michael Dewey > http://www.aghmed.fsnet.co.uk > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595