rm(list=ls()) #BSS8 (values: 0, 1, 2) (rare, frequent, continuous) # I accept the idea of killing myself. #SLCS1 0 #Owing to my capabilities, I have much potential. #SDT19 ! #I often do not feel very capable. #SLCS10 #I am a capable person. #SDT15 B #In my life I do not get much of a chance to show how capable I am. # Question #2. Is level of perceived burdensomeness related to level of suicidal ideation? # Answer # I will use correlation to establish any relation #---------------------------------------------------------------------- # all numerical data, but this data links to textual answers file = "VanOrden_for dist.csv" dall = read.csv(file) d = dall[c("bss8","slcs1","sdt19","slcs10","sdt15")] d # clean up unused variables rm(dall) # bss8 has many 999 undefines. Must get rid of them d = d[d$bss8 != 999,] d v1 = d$slcs1 v2 = d$sdt19 v3 = d$slcs10 v4 = d$sdt15 # plot one variable versus the other par(mfcol=c(2,2)) attach(d) z = max(bss8)-min(bss8) y = jitter(bss8,amount=z/100) p = plot(v1,y) p = plot(v2,y) p = plot(v3,y) p = plot(v4,y) detach(d) # There are 22 values, but only 10 points. Must change the type of # plot. Either add jitter, or a 3D plot, with count as the 3rd axis. # Or perform a correlation # Conclusion from plot # most results are that # bss8 is mostly 0 (6 out of 9) across bel2 (only 7 values) # print("*** Correlation of variable 1 with ideation ****") attach(d) cp = cor(bss8,v1, method="pearson") ck = cor(bss8,v1, method="kendall") cs = cor(bss8,v1, method="spearman") detach(d) # I need better way of printing print("cp= "); print(cp) print("ck= "); print(ck) print("cs= "); print(cs) # correlation of 0.4 : not much relation print("*** Correlation of variable 2 with ideation ****") attach(d) cp = cor(bss8,v2, method="pearson") ck = cor(bss8,v2, method="kendall") cs = cor(bss8,v2, method="spearman") detach(d) # I need better way of printing print("cp= "); print(cp) print("ck= "); print(ck) print("cs= "); print(cs) # correlation of 0.4 : not much relation