# Significant Difference between 2 measures

Third Update: Output from suggested code:

> fit1<- lm(cbind(Risk_Pct, PCT_Stocks_MF_1) ~ US_Born, regdata)
> summary(fit1)
Response Risk_Pct :


Call: lm(formula = Risk_Pct ~ US_Born, data = regdata)

Residuals: Min 1Q Median 3Q Max -6.527 -1.319 0.681 1.681 91.681

Coefficients: Estimate Std. Error t value Pr(>|t|)
(Intercept) 6.26699 0.05146 121.777 <2e-16 ***

## US_Born 0.05210 0.03113 1.673 0.0943 .

Signif. codes: 0 ‘’ 0.001 ‘’ 0.01 ‘’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 2.289 on 5041 degrees of freedom

(10957 observations deleted due to missingness) Multiple R-squared: 0.0005551, Adjusted R-squared: 0.0003569 F-statistic: 2.8 on 1 and 5041 DF, p-value: 0.09432

Response PCT_Stocks_MF_1 :

Call: lm(formula = PCT_Stocks_MF_1 ~ US_Born, data = regdata)

Residuals: Min 1Q Median 3Q Max -229.2 -155.2 -130.2 -130.2 812.7

Coefficients: Estimate Std. Error t value Pr(>|t|)
(Intercept) 241.195 7.577 31.831 <2e-16 ***

## US_Born -10.976 4.584 -2.394 0.0167 *

Signif. codes: 0 ‘’ 0.001 ‘’ 0.01 ‘’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 337 on 5041 degrees of freedom (10957 observations deleted due to missingness) Multiple R-squared: 0.001136, Adjusted R-squared: 0.0009379 F-statistic: 5.733 on 1 and 5041 DF, p-value: 0.01668

I think a problem with this may be that in the raw data for "PCT_Stocks_MF_1 there codes for "don't know" and "refused to answer" are given values of 998/999 which brings up the mean and messes with the results since no one actually has 998% of their assets invested in stocks

Second Update: Sample of 100 rows of the data

 regdata <- data.frame(HHID, US_Born, Born_In_US, Risk_Pct, PCT_Stocks_MF_1, Stocks_Pct, age, gender, Own_Home, Marital_Status, current_job_status,Total_Wealth,stock_market_expectations )

head(regdata, n = 100)

      HHID US_Born Born_In_US Risk_Pct PCT_Stocks_MF_1 Stocks_Pct
1   010004       1         NA        7              50         NA
2   010013       1         NA       10              NA         50
3   010038       1         NA        8              40         65
4   010038       1         NA        8              40         NA
5   010038       1         NA        8              40         85
6   010050       1         NA        5             998        998
7   010050       1         NA        5             998         NA
8   010325       1         NA        2             998         NA
9   010397       1         NA        3              75         NA
10  010397       1         NA        3              75        100
11  010433       1         NA        5              NA         NA
12  010451       5         NA        6              NA         50
13  010451       5         NA        6              NA         50
14  010451       5         NA        2              NA         NA
15  010481       1         NA        5             998         NA
16  010481       1         NA        5             998         NA
17  010481       1         NA        5             998         NA
18  010565       1         NA        7              NA         NA
19  010565       1         NA        7              NA         NA
20  010565       1         NA        7              NA         NA
21  010577       1         NA        5              NA         NA
22  010592       5         NA        8              NA         NA
23  010592       5         NA        8              NA         NA
24  010611       1         NA        0              NA         NA
25  010645       1         NA        4              NA         NA
26  010645       1         NA        4              NA         NA
27  010648       1         NA        3              NA         NA
28  010648       1         NA        5              NA         NA
29  010696       5         NA       NA              NA         NA
30  010769       1         NA        4              60         NA
31  010769       1         NA        4              60         50
32  010773       5         NA        2              50         NA
33  010773       5         NA        7              50          0
34  010773       5         NA        7              50         NA
35  010893       1         NA        6              NA         30
36  010893       1         NA        6              NA        100
37  010893       1         NA        6              NA         NA
38  010893       1         NA        6              NA         NA
39  010893       1         NA        6              NA         NA
40  010962       1         NA        5              NA         NA
41  010989       1         NA        4              NA         NA
42  010989       1         NA        4              NA         NA
43  011067       1         NA        8             998         NA
44  011256       1         NA        5              NA         NA
45  011332       1         NA        2              NA         NA
46  011341       1         NA        5              80        998
47  011341       1         NA        5              80         NA
48  011377       1         NA        5              NA        998
49  011377       1         NA        5              NA         NA
50  011377       1         NA        5              NA         NA
51  011377       1         NA        5              NA         NA
52  011378       5         NA        5              NA         NA
53  011466       1         NA        6              NA         NA
54  011620       1         NA        8             100        100
55  011620       1         NA        8             100         NA
56  011620       1         NA        8             100         NA
57  011620       1         NA        8             100         60
58  011620       1         NA        8             100         60
59  011626       5         NA        3              NA         NA
60  011626       5         NA        3              NA        998
61  011802       1         NA       10              NA         NA
62  011802       1         NA       10              NA         NA
63  011802       1         NA        8              NA        100
64  011802       1         NA        8              NA         NA
65  011802       1         NA        8              NA         NA
66  011810       1         NA       10              NA        999
67  011810       1         NA       10              NA         NA
68  011841       1         NA       10              NA        998
69  011881       5         NA        5              NA        100
70  011881       5         NA        5              NA        998
71  011902       1         NA        0              NA        999
72  011902       1         NA        0              NA         NA
73  011902       1         NA        0              NA         NA
74  011911       1         NA        7              NA        998
75  011911       1         NA        7              NA         NA
76  011911       1         NA        7              NA        998
77  011911       1         NA        7              NA         NA
78  011936       1         NA        6              NA          0
79  011936       1         NA        6              NA          0
80  011936       1         NA        6              NA         NA
81  011983       1         NA        8              NA         25
82  011983       1         NA        8              NA         NA
83  011999       1         NA        7              NA         NA
84  012005       1         NA        5              NA         NA
85  012005       1         NA        5              NA        998
86  012009       1         NA        3             998         50
87  012009       5         NA        6             998        998
88  012009       5         NA        6             998         NA
89  012033       1         NA        5             998         NA
90  012033       1         NA        0              NA          0
91  012104       1         NA        5              NA        998
92  012104       1         NA        5              NA          0
93  012112       1         NA        6              NA          0
94  012112       1         NA        6              NA        998
95  012161       1         NA        2              NA         NA
96  012161       1         NA        2              NA         NA
97  012161       1         NA        2              NA         NA
98  012166       1         NA       NA              NA         NA
99  012166       1         NA       NA              NA         NA
100 012166       1         NA        6              NA         NA
age gender Own_Home Marital_Status current_job_status
1    68      2        1              5                  5
2    76      1        2              4                  5
3    71      2        1              1                  1
4    71      2        1              1                  1
5    71      2        1              1                  1
6    73      2        1              5                  1
7    73      2        1              5                  1
8    75      2        2              5                  5
9    73      1        1              5                  1
10   73      1        1              5                  1
11   80      2        3              5                  5
12   76      2        1              1                  5
13   76      2        1              1                  5
14   74      1        1              1                  5
15   74      2        2              1                  5
16   74      2        2              1                  5
17   74      2        2              1                  5
18   82      1        7              5                  7
19   82      1        7              5                  7
20   82      1        7              5                  7
21   75      2        1              5                  5
22   77      2        1              6                  4
23   77      2        1              6                  4
24   73      2        2              6                  5
25   67      2        2              5                  5
26   67      2        2              5                  5
27   73      1        1              1                  5
28   74      2        1              1                  5
29   73      2        1              4                  5
30   58      2        1              5                  6
31   58      2        1              5                  6
32   77      2        1              1                  5
33   86      1        1              1                  5
34   86      1        1              1                  5
35   74      2        1              4                  1
36   74      2        1              4                  1
37   74      2        1              4                  1
38   74      2        1              4                  1
39   74      2        1              4                  1
40   74      2        1              5                  1
41   73      2        1              1                  5
42   73      2        1              1                  5
43   72      1        1              1                  5
44   73      1        2              1                  1
45   74      2        1              4                  5
46   75      2        1              5                  2
47   75      2        1              5                  2
48   68      2        1              1                  3
49   68      2        1              1                  3
50   68      2        1              1                  3
51   68      2        1              1                  3
52   77      1       NA              3                  5
53   62      2        2              6                  4
54   73      1       NA              1                  5
55   73      1       NA              1                  5
56   55      2       NA              1                  1
57   55      2       NA              1                  1
58   55      2       NA              1                  1
59   65      2        1              1                  6
60   65      2        1              1                  6
61   80      1        1              1                  5
62   80      1        1              1                  5
63   58      2        1              1                  1
64   58      2        1              1                  1
65   58      2        1              1                  1
66   76      1        1              1                  5
67   76      1        1              1                  5
68   78      1        1              1                  5
69   69      2        1              4                  6
70   69      2        1              4                  6
71   66      2        2              6                  5
72   66      2        2              6                  5
73   66      2        2              6                  5
74   75      1        1              1                  1
75   75      1        1              1                  1
76   75      1        1              1                  1
77   75      1        1              1                  1
78   75      2       NA              4                  5
79   75      2       NA              4                  5
80   75      2       NA              4                  5
81   71      1        1              1                  5
82   71      1        1              1                  5
83   77      1        1              1                  5
84   81      2        2              5                  1
85   81      2        2              5                  1
86   74      2        1              1                  6
87   87      1        1              1                  5
88   87      1        1              1                  5
89   73      1       NA              3                  5
90   73      2       NA              3                  5
91   79      2        1              5                  6
92   79      2        1              5                  6
93   66      2        2              5                  5
94   66      2        2              5                  5
95   76      2        7              5                  5
96   76      2        7              5                  5
97   76      2        7              5                  5
98   76      1        1              1                  5
99   76      1        1              1                  5
100  69      2        1              1                  5
Total_Wealth stock_market_expectations
1         901001                        NA
2           2000                        NA
3             NA                        NA
4             NA                        NA
5             NA                        NA
6        1224150                        75
7        1224150                        75
8          20000                        NA
9        1390000                        30
10       1390000                        30
11        196000                        50
12        194000                         5
13        194000                         5
14            NA                        80
15            NA                        10
16            NA                        10
17            NA                        10
18         51500                        NA
19         51500                        NA
20         51500                        NA
21         -2955                        NA
22        372000                        NA
23        372000                        NA
24          -925                        NA
25          4400                       100
26          4400                       100
27        303000                        20
28            NA                        50
29            NA                        NA
30            NA                        NA
31            NA                        NA
32            NA                        NA
33        304000                        NA
34        304000                        NA
35       1701000                        NA
36       1701000                        NA
37       1701000                        NA
38       1701000                        NA
39       1701000                        NA
40        -80500                         0
41            NA                        50
42            NA                        50
43       1072000                        60
44         22050                        NA
45            NA                        NA
46        135740                        NA
47        135740                        NA
48            NA                        NA
49            NA                        NA
50            NA                        NA
51            NA                        NA
52        112500                        50
53             0                        NA
54        400012                       100
55        400012                       100
56            NA                        NA
57            NA                        NA
58            NA                        NA
59        153700                        NA
60        153700                        NA
61        106000                        40
62        106000                        40
63            NA                       100
64            NA                       100
65            NA                       100
66            NA                        80
67            NA                        80
68         20000                        60
69            NA                        NA
70            NA                        NA
71            NA                        NA
72            NA                        NA
73            NA                        NA
74        353000                        50
75        353000                        50
76        353000                        50
77        353000                        50
78            NA                        30
79            NA                        30
80            NA                        30
81        771500                        NA
82        771500                        NA
83        100000                        75
84         42200                        40
85         42200                        40
86       1760500                        50
87            NA                        NA
88            NA                        NA
89         49000                        NA
90        -10500                        NA
91         17500                        NA
92         17500                        NA
93         54000                        NA
94         54000                        NA
95        -31000                        10
96        -31000                        10
97        -31000                        10
98            NA                        NA
99            NA                        NA
100           NA                        50


Update:I tried to run a "MANOVA" but am not entirely sure if I did this correct. Risk_Pct is the raw data risk measure 1 and PCT_Stocks_MF_1 is the raw data risk measure 2

> y<-cbind(Risk_Pct, PCT_Stocks_MF_1)

> fit.manova<-manova(y ~ US_Born)
summary(fit.manova, test = "Pillai")
Df    Pillai approx F num Df
US_Born      1 0.0016159   4.0788      2
Residuals 5041
den Df  Pr(>F)
US_Born     5040 0.01698 *
Residuals
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1
‘ ’ 1
> summary(fit.manova, test = "Roy")
Df       Roy approx F num Df
US_Born      1 0.0016186   4.0788      2
Residuals 5041
den Df  Pr(>F)
US_Born     5040 0.01698 *
Residuals
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1


## Also, if I have some variables I want to hold constant (such as "wealth") is it possible to do that in MANOVA? If so, how?

Original post: I'm trying to determine if immigration status is a significant determinant of risk preferences. In order to do this, I'm using two different measures of risk.

The first measure of risk has participants rate their level of risk on a scale from 0-10. I then divide that scale into 5 categories of risk: "no", "low", "some", "high", and "substantial" risk tolerance. The second measure of risk is based on the percentage(0-100%) of assets participants invest in stocks. They are also divided into the same 5 categories of risk: "no", "low", "some", "high", and "substantial" risk tolerance. In my preliminary analysis I found that using the first measure of risk I found that for both immigrants and natives the category with the most respondents was the "high" risk tolerance. Meanwhile, with the second measure of risk I found that for both immigrants and natives the category with the most respondents was "substantial" risk tolerance. How can I determine if there is a significant difference between these two measures of risk? I knew typically to find a significant difference you would use a t-test, but since they variables are categorical I can't find the mean. Even if I used the original data, not my groupings into risk tolerance data, the first variable is on a scale from 0-10 and the second variable is on a scale of 0-100 so the means are totally different. I am using "R" to do my analysis.

If it helps, here is a table of the the breakdown of risk measure 1, by immigration status and risk tolerance group:

             No     Low     Some    High    Substantial     Total
Native      4.5     3.54    31.74   52.11   8.11            100
Immigrant   9.34    3.67    23.19   47.71   16.08           99.99


And the same table, for risk measure 2:

            No      Low     Some     High   Substantial DK/RF   Total
Native      0.08%   1.81%   6.51%   17.38%  57.64%      16.58%  100.00%
Immigrant   0.00%   4.32%   14.59%  20.27%  48.65%      12.16%  99.99%

• I don't think the tables show correctly when printed like this, so the attached image is of these two tables enter image description here Thanks so much for any help on this situation
• I'm having a hard time with this, but I think you're asking a multivariate question with Risk Tolerance + Assets as response variable and Immigration Status as predictor variable. If so, then you're looking to solve it with a MANOVA. – Adam Quek May 13 '16 at 4:40
• Anyway, running analysis on summarise data are huge no-no. Go back to your raw data. The risks data may be recorded in different scales, but there are ways to normalised them (if that is even necessary.,..) – Adam Quek May 13 '16 at 4:41
• @ Adam Quek: Could you please explain why analyzing data that I put into categories would be a inaccurate? I understand for the first risk measure there would be 11 groups, but for the second risk measure there would be 101 groups so it makes a lot more sense to me to divide it into just 5 groups? – jkrzyminski May 13 '16 at 4:58
• I don't know whether or not it will be inaccurate. Just commenting here that a typical statistical analysis are usually run across numerous cases/rows to provide the variance in the recorded data. – Adam Quek May 13 '16 at 5:09
• The MANOVA output looks weird. Try running fit1<- lm(cbind(Risk_Pct, PCT_Stocks_MF_1) ~ US_Born, data) with the data stated. The summary will be a bit more informative than a straight manova. Also would be great if you could give a reproducible example of the data (say 100 rows of the dataset), and I can attempt to provide you with some specific answers (instead of just comments) – Adam Quek May 13 '16 at 5:28

Not really an answer but just a possible strategy to look at differences between US_Born.

# data exploration
library(dplyr)

means <- function(x) mean(x, na.rm=T)
dat %>% group_by(US_Born) %>% summarise_each(funs(means))

Source: local data frame [2 x 6]

US_Born     HHID Born_In_US Risk_Pct PCT_Stocks_MF_1 Stocks_Pct
(int)    (dbl)      (lgl)    (dbl)           (dbl)      (dbl)
1       1 10461.14         NA     5.25        459.1429  184.75000
2       5 10616.89         NA     5.75         50.0000   33.33333

# error with PCT_Stocks_MF_1?

table(dat$PCT_Stocks_MF_1) 40 50 60 75 998 3 4 2 2 6 # suspect 998 to be error code and not actual percentage data dat$PCT_Stocks_MF_1 <- sapply(dat$PCT_Stocks_MF_1, function(x)ifelse(x >100, NA, x)) # scale PCT_Stocks_MF_1 to be similar to Risk_Pct dat$PCT_Stocks_MF_1 <- dat$PCT_Stocks_MF_1/10 # run one-way ANOVA for Risk_Pct fit1 <- lm(Risk_Pct ~ as.factor(US_Born), dat) # visualise anova library(visreg) visreg(fit1)  #run one-way ANOVA for PCT_Stocks_MF_1 fit2 <- lm(PCT_Stocks_MF_1 ~ as.factor(US_Born)_, dat) visreg(fit2)  The data: dat <- structure(list(HHID = c(10004L, 10013L, 10038L, 10038L, 10038L, 10050L, 10050L, 10325L, 10397L, 10397L, 10433L, 10451L, 10451L, 10451L, 10481L, 10481L, 10481L, 10565L, 10565L, 10565L, 10577L, 10592L, 10592L, 10611L, 10645L, 10645L, 10648L, 10648L, 10696L, 10769L, 10769L, 10773L, 10773L, 10773L, 10893L, 10893L, 10893L ), US_Born = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L), .Label = c("1", "5"), class = "factor"), Born_In_US = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), Risk_Pct = c(7L, 10L, 8L, 8L, 8L, 5L, 5L, 2L, 3L, 3L, 5L, 6L, 6L, 2L, 5L, 5L, 5L, 7L, 7L, 7L, 5L, 8L, 8L, 0L, 4L, 4L, 3L, 5L, NA, 4L, 4L, 2L, 7L, 7L, 6L, 6L, 6L), PCT_Stocks_MF_1 = c(5, NA, 4, 4, 4, NA, NA, NA, 7.5, 7.5, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 6, 6, 5, 5, 5, NA, NA, NA), Stocks_Pct = c(NA, 50L, 65L, NA, 85L, 998L, NA, NA, NA, 100L, NA, 50L, 50L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 50L, NA, 0L, NA, 30L, 100L, NA)), .Names = c("HHID", "US_Born", "Born_In_US", "Risk_Pct", "PCT_Stocks_MF_1", "Stocks_Pct"), row.names = c(NA, -37L), class = "data.frame")  Edit: Added analysis on comparing both factors dat$US_Born <- as.factor(dat\$US_Born)
# linear model of multiple response to one predictor factor:
fit3 <- lm(cbind(Risk_Pct, PCT_Stocks_MF_1) ~ US_Born, dat)

# visualise multiple response with canonical discriminant analysis
library(candisc)
plot(candisc(fit3))


Not entirely sure if running CDA is required though...

• Note: I'd only taken the first 37 rows of the data for this. But hopefully you know where I'm heading... – Adam Quek May 13 '16 at 6:58