Hi, I am trying to do a simple multiple regression analysis that has one nominal variable (gender) and three numeric variables as independent variables and one numeric variable as dependent variable. So, I got a formula like this: summary(out.3 <- lm(scale(DV) ~ gender + scale(IV.1) + scale(IV.2) + scale(IV.3)) I tried to compare the outcome in R with the outcome in SPSS and found the results are different! I found that R and SPSS have the exact same outcome when every variable is numeric; however, whenever I included "gender (0/1)" variable in the equation, the result become different. I guess that SPSS automatically treat gender as a numeric variable and standardize it when running analysis. So, I tried to change "gender" to a numeric variable and ran analysis but the results were still not identical. What is the problem here and what is the right way to do this analysis? Thanks, Jay Yang -- View this message in context: http://r.789695.n4.nabble.com/Different-result-of-multiple-regression-in-R-and-SPSS-tp3679423p3679423.html Sent from the R help mailing list archive at Nabble.com.
Bert Gunter
2011-Jul-19 22:11 UTC
[R] Different result of multiple regression in R and SPSS
Answer: Contrasts, i.e. the parameterization of the categorical variable(s) df. ?contrasts may be of some help, but you really need to do some background studying of the linear models principles involved. Googling may provide tutorials. Also searching the mail archives, e.g.: https://stat.ethz.ch/pipermail/r-help/2009-February/187479.html -- Bert On Tue, Jul 19, 2011 at 2:39 PM, J. <seoulseoulseoul at gmail.com> wrote:> Hi, I am trying to do a simple multiple regression analysis that has one > nominal variable (gender) and three numeric variables as independent > variables and one numeric variable as dependent variable. > > So, I got a formula like this: > summary(out.3 <- lm(scale(DV) ~ ?gender + scale(IV.1) + scale(IV.2) + > scale(IV.3)) > > I tried to compare the outcome in R with the outcome in SPSS and found the > results are different! > I found that R and SPSS have the exact same outcome when every variable is > numeric; however, whenever I included "gender (0/1)" variable in the > equation, the result become different. > > I guess that SPSS automatically treat gender as a numeric variable and > standardize it when running analysis. So, I tried to change "gender" to a > numeric variable and ran analysis but the results were still not identical. > > What is the problem here and what is the right way to do this analysis? > Thanks, > > Jay Yang > > -- > View this message in context: http://r.789695.n4.nabble.com/Different-result-of-multiple-regression-in-R-and-SPSS-tp3679423p3679423.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >-- "Men by nature long to get on to the ultimate truths, and will often be impatient with elementary studies or fight shy of them. If it were possible to reach the ultimate truths without the elementary studies usually prefixed to them, these would not be preparatory studies but superfluous diversions." -- Maimonides (1135-1204) Bert Gunter Genentech Nonclinical Biostatistics
Thanks for the answer. However, I am still curious about which result I should use? The result from R or the one from SPSS? Why the results from two programs are different? Jay -- View this message in context: http://r.789695.n4.nabble.com/Different-result-of-multiple-regression-in-R-and-SPSS-tp3679423p3679511.html Sent from the R help mailing list archive at Nabble.com.
David Winsemius
2011-Jul-19 22:45 UTC
[R] Different result of multiple regression in R and SPSS
On Jul 19, 2011, at 6:29 PM, J. wrote:> Thanks for the answer. > > However, I am still curious about which result I should use? The > result from > R or the one from SPSS?It is becoming apparent that you do not know how to use the results from either system. The progress of science would be safer if you get some advice from a person that knows what they are doing.> Why the results from two programs are different?Different parametrizations. If I had to guess I would bet that the gender coefficient is R is exactly twice that of the one from SPSS. They are probably both correct in the context of their respective codings. -- David Winsemius, MD West Hartford, CT
Bert Gunter
2011-Jul-19 23:04 UTC
[R] Different result of multiple regression in R and SPSS
On Tue, Jul 19, 2011 at 3:45 PM, David Winsemius <dwinsemius at comcast.net> wrote:> > On Jul 19, 2011, at 6:29 PM, J. wrote: > >> Thanks for the answer. >>#########################>> However, I am still curious about which result I should use? The result >> from >> R or the one from SPSS? > > It is becoming apparent that you do not know how to use the results from > either system. The progress of science would be safer if you get some advice > from a person that knows what they are doing.########################## I nominate this for an R fortune. -- Bert> >> Why the results from two programs are different? > > Different parametrizations. If I had to guess I would bet that the gender > coefficient is R is exactly twice that of the one from SPSS. They are > probably both correct in the context of their respective codings. > > -- > David Winsemius, MD > West Hartford, CT > > ______________________________________________ > 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. >
@Dimitri: I tried to enter it as numeric and still got the same outcome. I still wonder if there is any way to get the same result from both programs. @David, Bert: Yes, I found that the gender coefficient is R is exactly twice that of the one from SPSS. Need to study on parametrization. Thanks, Jay -- View this message in context: http://r.789695.n4.nabble.com/Different-result-of-multiple-regression-in-R-and-SPSS-tp3679423p3679590.html Sent from the R help mailing list archive at Nabble.com.
Bert Gunter
2011-Jul-20 13:51 UTC
[R] Different result of multiple regression in R and SPSS
On Tue, Jul 19, 2011 at 4:19 PM, J. <seoulseoulseoul at gmail.com> wrote:> @Dimitri: I tried to enter it as numeric and still got the same outcome. I > still wonder if there is any way to get the same result from both programs.There is. ?C ?contrasts But of course you must do your homework to understand how to use these. (See the quote in my signature). -- Bert> @David, Bert: Yes, I found that the gender coefficient is R is exactly twice > that of the one from SPSS. Need to study on parametrization. > Thanks, > > Jay >PLEASE do read the posting guide http://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. >-- "Men by nature long to get on to the ultimate truths, and will often be impatient with elementary studies or fight shy of them. If it were possible to reach the ultimate truths without the elementary studies usually prefixed to them, these would not be preparatory studies but superfluous diversions." -- Maimonides (1135-1204) Bert Gunter Genentech Nonclinical Biostatistics 467-7374 http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm