There is a difference in the p- value from 0.000 and 0.012 when I am using SPSS. 0.000 when I am using the independent variable as scaled 0.012 if I am using the variable as ordinal. The independent variable is ordinal but it seems that R is using the variable as an scaled, because the P- Value is computed with 4.66e-06 so I am not sure which description I am misunderstanding: SPSS;: Covariates. Scale predictors <javascript:popup(N2C5F1_term,N2C5F1_def);> should be selected as covariates <javascript:popup(N2B079_term,N2B079_def);> in the model. Within combinations of factor levels (or cells <javascript:popup(N2AE3F_term,N2AE3F_def);>), values of covariates are assumed to be linearly correlated with values of the dependent variables. (A variable can be treated as scale when its values represent ordered categories with a meaningful metric, so that distance comparisons between values are appropriate. Examples of scale variables include age in years and income in thousands of dollars.) Factors. Categorical <javascript:popup(N2AD73_term,N2AD73_def);> predictors should be selected as factors <javascript:popup(N2B481_term,N2B481_def);> in the model. Each level <javascript:popup(N2B937_term,N2B937_def);> of a factor can have a different linear effect on the value of the dependent variable.(A variable with a discrete number of values; an ordinal or nominal variable. Categorical variables are often used as grouping variables or factors.) The data : http://biostatistic.de/temp/testr.csv lm.data<-lm( dependent ~ var2,family = gaussian) I don't know whether anybody could explain me the difference between SPSS and R results but if there are different results then one of them is wrong :-( And I do not know which of them. I hope I explained the problem understandable Regards Knut
Ordinal variables should be stored as ordered factors in R. See ?ordered. Andy From: Knut Krueger> > There is a difference in the p- value from 0.000 and 0.012 > when I am > using SPSS. > 0.000 when I am using the independent variable as scaled > 0.012 if I am using the variable as ordinal. > > The independent variable is ordinal but it seems that R is > using the variable as an scaled, because the P- Value is > computed with 4.66e-06 > > > so I am not sure which description I am misunderstanding: > SPSS;: > Covariates. Scale predictors > <javascript:popup(N2C5F1_term,N2C5F1_def);> > should be selected as covariates > <javascript:popup(N2B079_term,N2B079_def);> in the model. Within > combinations of factor levels (or cells > <javascript:popup(N2AE3F_term,N2AE3F_def);>), values of > covariates are > assumed to be linearly correlated with values of the > dependent variables. > (A variable can be treated as scale when its values represent ordered > categories with a meaningful metric, so that distance comparisons > between values are appropriate. Examples of scale variables > include age > in years and income in thousands of dollars.) > > Factors. Categorical <javascript:popup(N2AD73_term,N2AD73_def);> > predictors should be selected as factors > <javascript:popup(N2B481_term,N2B481_def);> in the model. Each level > <javascript:popup(N2B937_term,N2B937_def);> of a factor can have a > different linear effect on the value of the dependent variable.(A > variable with a discrete number of values; an ordinal or nominal > variable. Categorical variables are often used as grouping > variables or > factors.) > > The data : http://biostatistic.de/temp/testr.csv > > lm.data<-lm( dependent ~ var2,family = gaussian) > > I don't know whether anybody could explain me the difference between > SPSS and R results but if there are different results then > one of them > is wrong :-( > And I do not know which of them. > I hope I explained the problem understandable > > Regards Knut > > ______________________________________________ > 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 > >
Liaw, Andy schrieb:>Ordinal variables should be stored as ordered factors in R. See ?ordered. >thnk`s for your reply. I tried to store as ordered factors var <- as.ordered(var2) but if I am calling the lm(dependent~var) I get a long list of values. If I call var <- as.numeric(var2) lm(dependent~var) then I get: Residuals: Min 1Q Median 3Q Max -0.93563 0.01378 0.16272 0.25546 0.57862 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.79513 0.02787 64.412 < 2e-16 *** mean -0.28102 0.05993 -4.689 4.66e-06 *** the SPSS call and Result is: SPSS (13) Analyse General Linear Model Univariate Dependent Variable -> Dependent Fixed Factors -> var2 OK Tests of Between-Subjects Effects Dependent Variable: dependent | --------------- | ------------------------- | --- | ------------- | -------- | ---- | | Source | Type III Sum of Squares | df | Mean Square | F | Sig. | | --------------- | ------------------------- | --- | ------------- | -------- | ---- | | Corrected Model | 11,269(a) | 41 | ,275 | 1,668 | ,012 | | --------------- | ------------------------- | --- | ------------- | -------- | ---- | | Intercept | 361,340 | 1 | 361,340 | 2193,088 | ,000 | | --------------- | ----------------------- | --- | ----------- | -------- | ---- | | var2 | 11,269 | 41 | ,275 | 1,668 | ,012 | | --------------- | ----------------------- | --- | ----------- | -------- | ---- | | Error | 31,964 | 194 | ,165 | | | | --------------- | ----------------------- | --- | ----------- | -------- | ---- | | Total | 773,000 | 236 | | | | | --------------- | ----------------------- | --- | ----------- | -------- | ---- | | Corrected Total | 43,233 | 235 | | | | | --------------- | ----------------------- | --- | ----------- | -------- | ---- | a R Squared = ,261 (Adjusted R Squared = ,104) Maybe anybody is able to show me the difference between SPSS and R calls because the P value ic complete different The url for the Data (if anybody would like to try) http://biostatistic.de/temp/testr.csv Regards Knut
You got what you got in R because you didn't tell R that the variable is ordinal. You get a bunch of lines when you tell R that var2 is ordinal because the output you get is for the individual coefficients, not the variable. A k-level categorical variable (ordered or otherwise) has associated with it k-1 coefficients (thus the k-1 degrees of freedom). You probably want to do either summary() or anova() on the output of lm() to get the ANOVA table that give you the F-test for the term. There are good online materials that discuss these basic linear models in R (e.g., http://www.stat.lsa.umich.edu/~faraway/book/), and you would be well-served to peruse them instead of bumping your head on the wall over these confusions. From: Knut Krueger> > > Liaw, Andy schrieb: > > >Ordinal variables should be stored as ordered factors in R. > See ?ordered. > > > thnk`s for your reply. I tried to store as ordered factors > var <- as.ordered(var2) but if I am calling the > lm(dependent~var) I get a long list of values. > If I call > var <- as.numeric(var2) > lm(dependent~var) > > then I get: > > Residuals: > Min 1Q Median 3Q Max > -0.93563 0.01378 0.16272 0.25546 0.57862 > > Coefficients: > Estimate Std. Error t value Pr(>|t|) > (Intercept) 1.79513 0.02787 64.412 < 2e-16 *** > mean -0.28102 0.05993 -4.689 4.66e-06 *** > > the SPSS call and Result is: > > SPSS (13) > Analyse > General Linear Model > Univariate > Dependent Variable -> Dependent > Fixed Factors -> var2 > > OK > > > > > Tests of Between-Subjects Effects > Dependent Variable: dependent > | --------------- | ------------------------- | --- | ------------- | > -------- | ---- | > | Source | Type III Sum of Squares | df | Mean > Square | F > | Sig. | > | --------------- | ------------------------- | --- | ------------- | > -------- | ---- | > | Corrected Model | 11,269(a) | 41 | ,275 > > | 1,668 | ,012 | > | --------------- | ------------------------- | --- | ------------- | > -------- | ---- | > | Intercept | 361,340 | 1 | 361,340 | > 2193,088 | ,000 | > | --------------- | ----------------------- | --- | ----------- | > -------- | ---- | > | var2 | 11,269 | 41 | ,275 | > 1,668 | ,012 | > | --------------- | ----------------------- | --- | ----------- | > -------- | ---- | > | Error | 31,964 | 194 | ,165 > | | | > | --------------- | ----------------------- | --- | ----------- | > -------- | ---- | > | Total | 773,000 | 236 | > | | | > | --------------- | ----------------------- | --- | ----------- | > -------- | ---- | > | Corrected Total | 43,233 | 235 | > | | | > | --------------- | ----------------------- | --- | ----------- | > -------- | ---- | > a R Squared = ,261 (Adjusted R Squared = ,104) > > > Maybe anybody is able to show me the difference between SPSS > and R calls > because the P value ic complete different > The url for the Data (if anybody would like to try) > > http://biostatistic.de/temp/testr.csv > > Regards Knut > > > > > >