Readers, Using version 251 I tried the following command: lm(y~a+b,data=datafile) Resulting in, inter alia: ... coefficients (intercept) a 1.2 3.4 Packages installed: acepack ace() and avas() for selecting regression transformations adlift An adaptive lifting scheme algorithm akima Interpolation of irregularly spaced data alr3 Methods and data to accompany Applied Linear Regression 3rd edition car Companion to Applied Regression coda Output analysis and diagnostics for MCMC drc Analysis of dose-response curves EbayesThresh Empirical Bayes thresholding and related methods emplik Empirical likelihood ratio for censored/truncated data gllm Generalised log-linear model glmc Fitting Generalized Linear Models Subject to Constraints glmmML Generalized linear models with clustering glmpath L1 Regularization Path for Generalized Linear Models and Cox Proportional Hazards Model HydroMe Estimation of Soil Hydraulic Parameters from Experimental Data JGR JGR - Java Gui for R lmtest Testing Linear Regression Models locfit Local Regression, Likelihood and Density Estimation. mvtnorm Multivariate Normal and t Distributions NISTnls Nonlinear least squares examples from NIST nlme Linear and Nonlinear Mixed Effects Models nlstools Tools for nonlinear regression diagnostics nlt A nondecimated lifting transform for signal denoising nlts (non)linear time series analysis nnls The Lawson-Hanson algorithm for non-negative least squares (NNLS) plotrix Various plotting functions quantreg Quantile Regression Rcmdr ** No title available (pre-2.0.0 install?) ** sandwich Robust Covariance Matrix Estimators SparseM Sparse Linear Algebra sspline Smoothing Splines on the Sphere zoo Z's ordered observations Packages in library '/usr/lib/R/library': base The R Base Package boot Bootstrap R (S-Plus) Functions (Canty) class Functions for Classification cluster Cluster Analysis Extended Rousseeuw et al. codetools Code Analysis Tools for R datasets The R Datasets Package foreign Read Data Stored by Minitab, S, SAS, SPSS, Stata, Systat, dBase, ... graphics The R Graphics Package grDevices The R Graphics Devices and Support for Colours and Fonts grid The Grid Graphics Package KernSmooth Functions for kernel smoothing for Wand & Jones (1995) lattice Lattice Graphics MASS Main Package of Venables and Ripley's MASS methods Formal Methods and Classes mgcv GAMs with GCV smoothness estimation and GAMMs by REML/PQL nlme Linear and Nonlinear Mixed Effects Models nnet Feed-forward Neural Networks and Multinomial Log-Linear Models quadprog Functions to solve Quadratic Programming lattice Lattice Graphics MASS Main Package of Venables and Ripley's MASS methods Formal Methods and Classes mgcv GAMs with GCV smoothness estimation and GAMMs by REML/PQL nlme Linear and Nonlinear Mixed Effects Models nnet Feed-forward Neural Networks and Multinomial Log-Linear Models quadprog Functions to solve Quadratic Programming Problems. rcompgen Completion generator for R rpart Recursive Partitioning spatial Functions for Kriging and Point Pattern Analysis splines Regression Spline Functions and Classes stats The R Stats Package stats4 Statistical Functions using S4 Classes survival Survival analysis, including penalised likelihood. tcltk Tcl/Tk Interface tools Tools for Package Development utils The R Utils Package When using version 171 I entered the same command: lm(y~a+b,data=datafile) Resulting in, inter alia: ... coefficients (intercept) a b 5.6 7.8 9.01 Packages installed: base The R base package boot Bootstrap R (S-Plus) Functions (Canty) class Functions for classification cluster Functions for clustering (by Rousseeuw et al.) ctest Classical Tests eda Exploratory Data Analysis foreign Read data stored by Minitab, S, SAS, SPSS, Stata, ... grid The Grid Graphics Package KernSmooth Functions for kernel smoothing for Wand & Jones (1995) lattice Lattice Graphics lqs Resistant Regression and Covariance Estimation MASS Main Library of Venables and Ripley's MASS methods Formal Methods and Classes mgcv Multiple smoothing parameter estimation and GAMs by GCV modreg Modern Regression: Smoothing and Local Methods mva Classical Multivariate Analysis nlme Linear and nonlinear mixed effects models nls Nonlinear regression lqs Resistant Regression and Covariance Estimation MASS Main Library of Venables and Ripley's MASS methods Formal Methods and Classes mgcv Multiple smoothing parameter estimation and GAMs by GCV modreg Modern Regression: Smoothing and Local Methods mva Classical Multivariate Analysis nlme Linear and nonlinear mixed effects models nls Nonlinear regression nnet Feed-forward neural networks and multinomial log-linear models rpart Recursive partitioning spatial functions for kriging and point pattern analysis splines Regression Spline Functions and Classes stepfun Step Functions, including Empirical Distributions survival Survival analysis, including penalised likelihood. tcltk Tcl/Tk Interface tools Tools for package development ts Time series functions Why do I get different results when entering the same equation command? The correct answer was obtained using the older version of the software, so I want to replicate using the new version, which is installed onto a new pc that I am using. Any advice. Yours, rhelp at conference.jabber.org
Did you happen to notice the part at the bottom of every message about "provide commented, minimal, self-contained, reproducible code"? Considering that the result you quote from "251" has 2 coefficients and the result from "171" has 3 coefficients one might contemplate the possibility that you are fitting different models or perhaps using different data. However we can't verify anything about the causes because we have no data regarding the problem. Perhaps you are Brian Ripley's evil twin trying to provoke him. I would say that references to a nonexistent version "171" are deliberately provocative. ("251" could be considered a lazy person's attempt at 2.5.1 but "171" which presumably came after "251" doesn't make any sense to me.) On Thu, May 15, 2008 at 7:05 AM, e-letter <inpost at gmail.com> wrote:> Readers, > > Using version 251 I tried the following command: > > lm(y~a+b,data=datafile) > > Resulting in, inter alia: > ... > coefficients > (intercept) a > 1.2 3.4 > > Packages installed: > acepack ace() and avas() for selecting regression > transformations > adlift An adaptive lifting scheme algorithm > akima Interpolation of irregularly spaced data > alr3 Methods and data to accompany Applied Linear > Regression 3rd edition > car Companion to Applied Regression > coda Output analysis and diagnostics for MCMC > drc Analysis of dose-response curves > EbayesThresh Empirical Bayes thresholding and related > methods > emplik Empirical likelihood ratio for > censored/truncated data > gllm Generalised log-linear model > glmc Fitting Generalized Linear Models Subject to > Constraints > glmmML Generalized linear models with clustering > glmpath L1 Regularization Path for Generalized Linear > Models and Cox Proportional Hazards Model > HydroMe Estimation of Soil Hydraulic Parameters from > Experimental Data > JGR JGR - Java Gui for R > lmtest Testing Linear Regression Models > locfit Local Regression, Likelihood and Density > Estimation. > mvtnorm Multivariate Normal and t Distributions > NISTnls Nonlinear least squares examples from NIST > nlme Linear and Nonlinear Mixed Effects Models > nlstools Tools for nonlinear regression diagnostics > nlt A nondecimated lifting transform for signal > denoising > nlts (non)linear time series analysis > nnls The Lawson-Hanson algorithm for non-negative > least squares (NNLS) > plotrix Various plotting functions > quantreg Quantile Regression > Rcmdr ** No title available (pre-2.0.0 install?) ** > sandwich Robust Covariance Matrix Estimators > SparseM Sparse Linear Algebra > sspline Smoothing Splines on the Sphere > zoo Z's ordered observations > > Packages in library '/usr/lib/R/library': > base The R Base Package > boot Bootstrap R (S-Plus) Functions (Canty) > class Functions for Classification > cluster Cluster Analysis Extended Rousseeuw et al. > codetools Code Analysis Tools for R > datasets The R Datasets Package > foreign Read Data Stored by Minitab, S, SAS, SPSS, > Stata, Systat, dBase, ... > graphics The R Graphics Package > grDevices The R Graphics Devices and Support for Colours > and Fonts > grid The Grid Graphics Package > KernSmooth Functions for kernel smoothing for Wand & Jones > (1995) > lattice Lattice Graphics > MASS Main Package of Venables and Ripley's MASS > methods Formal Methods and Classes > mgcv GAMs with GCV smoothness estimation and GAMMs > by REML/PQL > nlme Linear and Nonlinear Mixed Effects Models > nnet Feed-forward Neural Networks and Multinomial > Log-Linear Models > quadprog Functions to solve Quadratic Programming > lattice Lattice Graphics > MASS Main Package of Venables and Ripley's MASS > methods Formal Methods and Classes > mgcv GAMs with GCV smoothness estimation and GAMMs > by REML/PQL > nlme Linear and Nonlinear Mixed Effects Models > nnet Feed-forward Neural Networks and Multinomial > Log-Linear Models > quadprog Functions to solve Quadratic Programming > Problems. > rcompgen Completion generator for R > rpart Recursive Partitioning > spatial Functions for Kriging and Point Pattern > Analysis > splines Regression Spline Functions and Classes > stats The R Stats Package > stats4 Statistical Functions using S4 Classes > survival Survival analysis, including penalised > likelihood. > tcltk Tcl/Tk Interface > tools Tools for Package Development > utils The R Utils Package > > When using version 171 I entered the same command: > > lm(y~a+b,data=datafile) > > Resulting in, inter alia: > ... > coefficients > (intercept) a b > 5.6 7.8 9.01 > > Packages installed: > base The R base package > boot Bootstrap R (S-Plus) Functions (Canty) > class Functions for classification > cluster Functions for clustering (by Rousseeuw et al.) > ctest Classical Tests > eda Exploratory Data Analysis > foreign Read data stored by Minitab, S, SAS, SPSS, > Stata, ... > grid The Grid Graphics Package > KernSmooth Functions for kernel smoothing for Wand & > Jones (1995) > lattice Lattice Graphics > lqs Resistant Regression and Covariance Estimation > MASS Main Library of Venables and Ripley's MASS > methods Formal Methods and Classes > mgcv Multiple smoothing parameter estimation and > GAMs by GCV > modreg Modern Regression: Smoothing and Local Methods > mva Classical Multivariate Analysis > nlme Linear and nonlinear mixed effects models > nls Nonlinear regression > > lqs Resistant Regression and Covariance Estimation > MASS Main Library of Venables and Ripley's MASS > methods Formal Methods and Classes > mgcv Multiple smoothing parameter estimation and > GAMs by GCV > modreg Modern Regression: Smoothing and Local Methods > mva Classical Multivariate Analysis > nlme Linear and nonlinear mixed effects models > nls Nonlinear regression > nnet Feed-forward neural networks and multinomial > log-linear models > rpart Recursive partitioning > spatial functions for kriging and point pattern > analysis > splines Regression Spline Functions and Classes > stepfun Step Functions, including Empirical > Distributions > survival Survival analysis, including penalised > likelihood. > tcltk Tcl/Tk Interface > tools Tools for package development > ts Time series functions > > Why do I get different results when entering the same equation > command? The correct answer was obtained using the older version of > the software, so I want to replicate using the new version, which is > installed onto a new pc that I am using. Any advice. > > Yours, > > rhelp at conference.jabber.org > > ______________________________________________ > R-help at r-project.org 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. >
Hi, To get help with this problem, you will have to create an example that others can duplicate. That is why each message to the list says (at the bottom): "PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code." Before you do any of that, please run some textbook examples using lm(), which will tell you whether lm() is working or not. It is ***extremely*** unlikely that for a function as stable and heavily- used as lm(), the same data and the same command produced different results on different computers, different versions of R, or different OSs. Your list of packages installed is not informative, because these packages are unlikely to affect your running of lm(). To tell the list which version of R you are running please include the output of sessionInfo(). You will find that many people are eager to help beginners, as long as they give enough information about the problem they encountered. _____________________________ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400 Charlottesville, VA 22904-4400 Parcels: Room 102 Gilmer Hall McCormick Road Charlottesville, VA 22903 Office: B011 +1-434-982-4729 Lab: B019 +1-434-982-4751 Fax: +1-434-982-4766 WWW: http://www.people.virginia.edu/~mk9y/ On May 15, 2008, at 8:05 AM, e-letter wrote:> Readers, > > Using version 251 I tried the following command: > > lm(y~a+b,data=datafile) > > Resulting in, inter alia: > ... > coefficients > (intercept) a > 1.2 3.4 > > Packages installed: > <snip> > Why do I get different results when entering the same equation > command? The correct answer was obtained using the older version of > the software, so I want to replicate using the new version, which is > installed onto a new pc that I am using. Any advice. > > Yours, > > rhelp@conference.jabber.org[[alternative HTML version deleted]]
Professor Kubovy As you instructed, below is the command terminal output: sessionInfo() R version 2.5.1 (2007-06-27) i586-mandriva-linux-gnu locale: LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.UTF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods" [7] "base" Yours,
On 15/05/2008, Michael Kubovy <kubovy at virginia.edu> wrote:> Hi, > > Your reply doesn't help you with your lm() problem. You need to show the > problem with lm() as well. Your original message was unclear on what is > wrong.The problem I have with lm() is that when I enter this command, I obtain different answers!> > So here is a todo list, before you do anything else: > (1) Get the most recent version of R (2.7.0).No thank you. I rely on my urpmi repository.> (2) Make sure you issue the command update.packages() at least once a weekYou must be joking! Waste my time every week to perform a basic task such as interpolation, or least fit squares linear regression? I am a novice seeking only to perform rudimentary statistics.> (3) Find a textbook example of a linear model. Run it using lm(). > (a) If it comes out right, then nothing is wrong with the function, and > you've been confused somewhere else.Well, I sought a statistician who showed me how to do this task using mathematica. Despite advice otherwise, I am interested to learn how to perform this basic task using r because it's free and and use linux. The output from the lm() command using version 171 yielded the same result as obtained from the statistician who helped me. In contrast enabling the version 251 did not yield the same result, hence this original post.> (b) If it comes out wrong, read the help page for lm(), get a textbook or > read some of the introductory materials on CRAN. lm() is never wrong (this > is not necessarily true for all R functions, but it's true for most). > (4) Before you ask the list for help, read > http://www.R-project.org/posting-guide.html carefully, and > follow the rules religiously.Done, but not religiously. ;)> (5) Generally do not reply to the person who helped you, but to the list. > You can cc the person who helped you, but that is rarely appropriate (avoid > cluttering people's mailboxes). > (6) Do *not* be rude (as in your recent message). You will be shunned. > Ripley and Bates are two of the most distinguished statisticians alive. > Accept their criticism gracefully.Telling a user the software version is nonexistent is equally rude; I've little respect for such typical techie petulance.> (7) Your most recent message doesn't help enough. Write it so that if I copy > and paste your code into R, I can reproduce the result you're worried about.I didn't know you can copy data directly into r; why not simply copy the text to your text editor and save in csv format? Yours,
On Thu, May 15, 2008 at 3:05 PM, e-letter <inpost@gmail.com> wrote:> Using version 251 I tried the following command: > > lm(y~a+b,data=datafile) > > Resulting in, inter alia: > ... > coefficients > (intercept) a > 1.2 3.4 >[...]> When using version 171 I entered the same command: > > lm(y~a+b,data=datafile) > > Resulting in, inter alia: > ... > coefficients > (intercept) a b > 5.6 7.8 9.01 >> Why do I get different results when entering the same equation > command? The correct answer was obtained using the older version of > the software, so I want to replicate using the new version, which is > installed onto a new pc that I am using. Any advice. >First check if your data frame is the same on both occasions. (It definitely wasn't the data set you provided in a later message - so it sounds possible you've made another error.) Secondly, try to make sure you're copying real output here. You should have three coefficients if you ask for three. Third, check your lm function: "lm"%in%ls() Maybe an evil twin of yours has modified it, for instance, this way: lm<- function(...) cat("coefficients\ (intercept) \ta\ 1.2 \t\t3.4\n") [[alternative HTML version deleted]]